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.

One thought on “fish & zsh: alternative shells”

Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s