Liquid Prompt: power bash & zsh prompt

We explored several power prompts and bars for bash and vim earlier. However, Liquid Prompt deserves a special mention due to the information it shows and flexibility of customization. It takes power prompts to next level from bashstyle-ng by bringing extensive system information right at the prompt. Liquid Prompt is a script that works with bash and zsh. Continue reading Liquid Prompt: power bash & zsh prompt

ttystudio: awesome terminal recorder

terminalThere are several utilities to record your terminal as a gif (like ttyrec). However, most of them have a number of dependencies and the procedure is rather cumbersome. ttystudio is a new tool developed with zero dependencies and support for gif and png output files. Continue reading ttystudio: awesome terminal recorder

The Fuck: fix the last command

terminalThere are a few ways to rectify specific issues with your last command like sudo !!. But how about a utility that could correct wrong commands or typos as well? Before proceeding further, I must state that I am not responsible for the NSFW name of the tool and would strongly suggest the author changes it to something civil. Continue reading The Fuck: fix the last command

fish & zsh: alternative shells

In its simplest definition, shell is a program that takes commands from the keyboard and gives them to the operating system to perform. Most of us use bash as our regular shell and there’s no doubt it’s a very capable one. How about some variety though? This article covers fish and zsh, two alternative shells which have their own advantages and unique features.

fish

fish is written for efficient sessions and ease of navigation. Let’s take a look at its features:

  • web browser like autosuggestions
  • syntax highlighting for commands on the go
  • underlined valid paths
  • tab completion/suggestion
  • for partial commands, up arrow jumps to mathcing commands only, not the earlier command in history
  • fully scriptable
  • man page [switch] completions
  • natively supports term256 for quality VGA rendering
  • web base configuration and help
  • no hidden settings, special features are default

To install fish on Ubuntu:

$ sudo apt-get install fish

The config file for fish (to add stuff like alias etc.) is ~/.config/fish/config.fish. You may need to create it the first time.

To generate auto-completion files from man pages of installed programs, run:

$ fish_update_completions

zsh

zsh (aka Z Shell) is a very advanced shell designed for interactive use. Many of the useful features of bash, ksh, and tcsh were incorporated into zsh; many original features were added. Feature highlights:

  • filename generation: extended globbing, grouping, omission
    ls -l **/*.log

    **/ means recursive globbing

  • shell functions and aliases
  • autosuggestions via zsh-autosuggestions
  • directory stacks, autopushd
  • extra functionalities like zmv, zcalc, zparseopts
  • command / process substitution
    In bash

    vimdiff <(ls /bin) <(ls /usr/bin)

    will create two pipes for output of each ls. Sometimes vimdiff needs to run two passes, in which case the above fails if the outputs are large. However, in zsh lingo

    vimdiff =(ls /bin) =(ls /usr/bin)

    will create two temp normal files, and vimdiff works fine

  • shared history
  • history substring search
  • simple configuration (also check oh-my-zsh)
  • syntax highlighting
  • cmdline editing
  • switch completion
  • output redirection to multiple destinations
  • default key bindings for certain functions
  • predefined shell parameters and parameter substitution
  • floating point arithmetic support
    number=$((3.5 / 4.2))
  • hashes support
  • prompt customization
  • login/logout watching
  • concept, variable, function, key indexes
  • spelling correction for common commands

To install zsh on Ubuntu:

$ sudo apt-get install zsh

The config file for zsh is ~/.zshrc.

Test drive

If you are impressed by fish or zsh, you can change to any of these shells (and back to bash). I am trying out fish myself.

To switch to fish, run:

$ chsh -s /usr/bin/fish

You can also use drop-down terminal AltYo which allows you to use a custom shell.

xonsh: intelligent modern shell

xonsh (pronounced conch) is a new shell developed by Anthony Scopatz. xonsh is written in python and is BASH compatible to some extent. The language of xonsh is a superset of python 3.4 with additional shell primitives.

Features

  • inline math expression evaluation
  • typed environment variables
  • tab completion everywhere
  • file names an be globbed with regular expressions
  • multiline input
  • built-in python functionality: import modules, print values, create and use literal data types, such as ints, floats, lists, sets, and dictionaries
  • loops, functions and classes
  • python-mode and subprocess-mode
  • pipes (|), redirection (>, >>) and non-blocking mode (&), file globbing (*)

Installation

To install xonsh, run:

$ sudo pip install xonsh

Usage

xonsh has a very well-explained tutorial to kickstart with.

Webpage: xonsh

clf: Commandlinefu snippet search

terminalWhat if you wanted to share your audio over the LAN using simple shell scripts? It’s not very easy to do it b yourself without spending some amount of time. However, people have done it and shared their scripts on the internet. Commandlinefu is a huge repository of such innovative scripts. What if you could search access those scripts when you needed one?

Of course, you can fire your browser and search. But if you are terminal-savvy, you may not consider the solution very elegant. clf is a python tool that enables you to search Commandlinefu and view the snippets matching your description. Take your pick! Nifty, eh? You can even use it over a remote terminal without opening the browser.

It also allows you to browse the Commandlinefu archive.

Installation

To install clf, run:

$ sudo pip install clf

Usage

The basic syntax of the command is:

$ clf description
e.g.
$ clf recursive line count

# Recursive Line Count
find ./ -not -type d | xargs wc -l | cut -c 1-8 | awk '{total += $1} END {print total}'

# Recursive Line Count
find * -type f -not -name ".*" | xargs wc -l

Option details and examples:

Command line tool to search snippets on Commandlinefu.com

Usage:
  clf --browse [options]
  clf  [options]
  clf  ... [options]

Options:
  -h, --help     Show this help.
  -v, --version  Show version.
  -c, --color    Enable colorized output
  -b, --browse   Browse the Commandlinefu.com archive.
  --order=ORDER  The order output (votes|date) [default: votes]

Examples:
  clf tar
  clf python server
  clf --browse --order=date

On GitHub: clf