hstr: history the easy way

The most common way of searching history is either history|grep ... or <Ctrl-r>. However, let’s face it, both of them are tedious and sometimes it’s really difficult to find that exact long and complex command you barely want to type in again. What if a tool could list all the matches visually and let you select the right command using search as you type? hstr is a new tool that does exactly the same thing. It’s a suggestion box or list of your command history with a lot of functionality built-in. Continue reading hstr: history the easy way

Generate your bash prompt

terminalGenerating a bash prompt may be intimidating with all those options and colour codes to remember or look up. You can create fancy bash prompts online now. There’s absolutely nothing to remember, simply drag and drop what you want to show in your prompt. There are some examples to start with and the rest is quite easy thanks to the interface.

You can choose the colours too!

Once done, paste your generated bash PS1 to ~/.bashrc.

Webpage: .bashrc generator

clif: record CLI as gif

We explored several tools to record terminal and share them. Most of those use tools like ttyrec or script or follow the same principles. clif is a fresh tool that records console sessions as optimized gif files. It uses web technologies like JS to do the job.

clif depends on child_pty, term.js omggif and phantomjs. child_pty is used to spawn a pseudo terminal which is captured. The captured frames are sent to phantomjs headless browser to render using term.js and screenshot. The gif is created using omggif.

Features

  • Small GIFs
  • High quality (anti-aliased fonts)
  • Rendered with CSS/JS, customizable
  • Real-time parallel rendering
  • Frame aggregation and customizable FPS
  • Support for titles Terminal.app-style
  • Supports Linux and OSX

Installation

To install clif, run:

$ sudo npm install -g clif

Usage

To record a session as out.gif, run:

$ clif out.gif

Type exit to finish the recording.

Available options:

Syntax: clif [options] 
-h, --help      output usage information
-V, --version   output the version number
-c, --cols      cols of the term [90]
-r, --rows      rows of the term [30]
-s, --shell     shell to use [/bin/bash]
-f, --fps       frames per second [8]
-q, --quality   frame quality 1-30 (1 = best|slowest) [5]

On GitHub: clif

Similar software

To install on Ubuntu:

$ sudo apt-get install byzanz

Navigate up without cd ..

terminalSometimes navigating up to a higher directory level from a deeper one in the file-system becomes tedious. Specially when you have to start counting the ..s. Here’s a handy script I came across Reddit today (and simplified greatly by one of our readers) that can reduce your directory changing woes.

Add the following to your ~/.bashrc:

up()
{
    for ((i=1; i<=${1:-1}; i++));
    do
        cd ..
    done
}

Usage:

$ up
OR
$ up 1

$ up 2
$ up 6

It should be obvious by now that the parameter to up is the level, up or up 1 being equivalent to cd ..

goto & shmark: navigate faster

terminalWe explored go2 in one of our earlier articles on faster terminal navigation. However, alternatives galore in the cmdline world and developers come up with new solutions now and then. We found goto and shmark, two more tools to navigate efficiently using bookmarks.

goto

Saves directories as bookmarks (or shortcuts) and does a fuzzy search to find files and directories. The bookmarks are save under ~/.GOTO directory as plaintext files. For example, the bookmark work will be saved as work.skt. As you might have guessed this works like symbolic links and we think a sorted structure or single file based implementation would have been faster for navigation. Anyway, it’s still handy and the fuzzy search logic is distinct from the navigation logic.

Installation

Run the following commands to install goto:

$ git clone https://github.com/ankitvad/goto.git
$ cd goto
$ make install

Usage

  • goto a bookmark or absolutelocation
    $ goto <bookmark>
    $ goto <location>
  • Save the current directory as bookmark
    $ goto -s
  • List all save bookmarks
    $ goto -l
  • Delete a saved bookmark
    $ goto -d
  • Print the absolute path for a bookmark
    $ goto -p
  • Fuzzy find files/directories matching regex in current directory
    $ goto -f

 

shmark

Another minimal bookmarking tool that uses a single file based approach to record the bookmarks.

Installation

$ git clone https://github.com/charles-l/shmark.git
$ cd shmark
$ chmod +x shmark.sh
$ sudo mv shmark.sh /usr/bin/

Usage

You need to source the shmark.sh file (check below) to run the commands. Assuming that you have saved the file in /usr/bin/ as above the command to source the file is:

$ source /usr/bin/shmark.sh

You may want to add the command in ~/.bashrc to source the file when you run your terminal.

  • To add a bookmark for the current directory
    $ m <bookmark>
  • To cd to a bookmark
    $ g <bookmark>
  • Save all bookmarks to ~/.shmarks
    $ savemarks

    Note that sourcing shmarks.sh is necessary to load all saved bookmarks.

Script to share directory as webserver

terminalMy favourite tool to share a directory over http is boa. However, new options are always welcome, more so when it is a simple script. A developer has shared such a script that uses CGI to share a directory as a webserver.

To use the script and serve a directory as a HTTP server, run:

$ curl -L http://tinyurl.com/servesh1 | sh

The script is published as a GitHub gist and you can go thorugh it here.

AltYo: a drop-down terminal

If you have used terminal emulators like guake or tilda the concept of altyo shouldn’t be new – it is a terminal emulator always running in the background with a hotkey binding. This is convenient because you always have a handy terminal with the context of your last working state. altyo is written in vala, depends only on libvte and gtk3. It is a very rich application with a strong focus on visual and usability aspects. Though evilvte is my favourite terminal emulator it is not very flexible with configuration at runtime. altyo comes with several configurable features:

  • Autostart with desktop session.
  • Autostart programs, for example, start mocp and mutt in new tabs by default.
  • Open unlimited tabs, even with long terminal title. If tabs do not fit in the row, they move to a new line.
  • Drag and drop tabs. Tabs does not stand out from the terminal. Lock tabs. Hotkey for tabs.
  • <Ctrl-Right> to open links in the default browser.
  • Program will warn if you try to close the terminal with an important program (ssh,wget pattern is customizable), even if program is running in the background.
  • Delayed “Close tab”: you have 10 seconds before tab is actually closed, so if you change your mind, press <Ctrl-Shift-r> to restore tab. You may restore tab from terminal popup menu as well.
  • All options can be configured via graphical settings dialog.
  • Multi monitor support.
    > Setup default monitor.
    > Individual window size and position for each monitor.
    > Program has mode “Follow the mouse”, in this mode, after hiding, window will shown on same monitor with mouse pointer.
  • Tiling window manager support (usual window). Use --standalone cmdline option to run in tiling window manager.
  • Multiple instances. You may run several instances of altyo simultaneously.

To install altyo on Ubuntu:

$ sudo add-apt-repository ppa:linvinus/altyo
$ sudo apt-get update
$ sudo apt-get install altyo

Though the memory usage seemed high on first run, it has reduced with time (even immediately after desktop login) and is slightly higher than that of evilvte now.

Webpage: altyo

byobu: screen & tmux with terminal session sharing

Byobu is heavily influenced by GNU Screen and Tmux, two efficient terminal multiplexers. It comes with several improvements like enhanced profiles, convenient keybindings, configuration utilities, and toggle-able system status notifications for both the GNU Screen window manager and the Tmux terminal multiplexer. Byobu can handle multiple terminal sessions simultaneously. But its main power lies in the ability to share a terminal session among multiple users. Here’s how to do terminal session sharing with byobu.

To start the first session, run

$ byobu

All subsequent users interested in the session can just run byobu (yes, same command) and connect to the first session. It works even if you are connected remotely over ssh. This session can be controlled by everyone who connected to it.

Common keybindings

 F2 - Create a new window
 F3 - Move to previous window
 F4 - Move to next window
 F5 - Reload profile
 F6 - Detach from this session
 F7 - Enter copy/scrollback mode
 F8 - Re-title a window
 F9 - Configuration Menu
 F12 -  Lock this terminal
 shift-F2 - Split the screen horizontally
 ctrl-F2 - Split the screen vertically
 shift-F3 - Shift the focus to the previous split region
 shift-F4 - Shift the focus to the next split region
 shift-F5 - Join all splits
 ctrl-F6 - Remove this split
 ctrl-F5 - Reconnect GPG and SSH sockets
 shift-F6 - Detach, but do not logout
 alt-pgup - Enter scrollback mode
 alt-pgdn - Enter scrollback mode
 Ctrl-a $ - show detailed status
 Ctrl-a R - Reload profile
 Ctrl-a ! - Toggle key bindings on and off
 Ctrl-a k - Kill the current window
 Ctrl-a ~ - Save the current window's scrollback buffer

Many options are available to customize byobu from the Configuration Menu (F9).

Byobu is available in the default repos of major distros. To install byobu on Ubuntu:

$ sudo apt-get install byobu

Webpage: byobu

Record, share terminal sessions

terminalThis article is the continuation of the earlier article to record a terminal session as an animated gif image. I found some more services which make it very easy to record your terminal activities and share with friends or for future reference.

Asciinema

Asciinema was inspired by script. Record terminal and share online with friends. You can copy and paste text from the recordings. On the downside, it lets you watch the video online only and if you need more control like embed or delete you need to create an account.

  • To install on Ubuntu
    $ sudo apt-add-repository ppa:zanchey/asciinema
    $ sudo apt-get update
    $ sudo apt-get install asciinema

    To install on other distros check the instructions.

  • Start the recording
    $ asciinema rec
  • Press ^D or type exit to finish recording
  • The app will ask whether to upload the video. Press y. If you don’t you will not have any local copy. Once the upload is complete it will show you the link to the video.
  • If you have an account (which you need to create from the webpage) you can then authenticate and have more control on the video:
    $ asciinema auth

Monitor

Monitor is the newest tool in this list. The recordings are uploaded to commands.com. You can also download the scripts (check the installation step).

  • The easiest way to install on Ubuntu is to install using a captured script
    $ curl commands.io/install-monitor-ubuntu
  • To use Monitor you need to have an account on commands.com.
  • Usage is simaple
    $ monitor {-d} {-h} {-u }
        -d : do not delete /tmp files
        -h : help
        -u : commands.com username

    For example:

    $ monitor -u myusername

Showterm

Showterm is a Ruby tool that follows a similar philosophy as the previous two. There are options to provide the playing speed (slow or fast) in the embeddable link URL.

  • Install on Ubuntu (in case you do not have Ruby). Check for other option here.
    $ curl showterm.io/showterm > ~/bin/showterm
    $ chmod +x ~/bin/showterm
  • Run showterm
    $ showterm
    //or if you haven't installed showterm
    $ bash <(curl record.showterm.io)
  • Type exit ot ^D to end recording. Showterm will upload the video and show you the link to the video.

TermRecord

TermRecord save your recording locally as a sel-contained html file and you can replay it in your browser. It doesn’t have any corresponding web service to upload the recordings. TermRecord comes with several templates for the generated html files. You an play around with them. TermRecord also depends on script, term.js, Ubuntu Mono font and Jinja2.

  • The easiest way to install it is
    $ sudo apt-get install python-pip
    $ sudo pip install TermRecord
    $ TermRecord -o /path_to_output/record.html

PLAYterm

Run ttyrec, record your session and upload the .tty file to PLAYterm. It will play the recording in a beautiful embedded player. Share the link with your friends or embed on your website.