Since starting at NetEngine I’ve been challenged to optimise my work environment, including my shell.

I’m not a fan of heavy customisation. Previously, I worked across many different machines and so I stuck to plain old bash and vim for any terminal work. I’ve avoided heavy customisation of my dotfiles, or using someone else’s customisation.

Now that I’m working from one machine everyday there’s a few features I wanted to have:

  1. tabbing for everything (e.g. git checkout )
  2. smart history (type a command and then press up to cycle through previous commands of just that type)
  3. useful git information at my prompt

These things are easy enough to add to bash or zsh and I started doing this, but one weekend I decided to give fish a go.

fish is a fully-equipped command line shell (like bash or zsh) that is smart and user-friendly. fish supports powerful features like syntax highlighting, autosuggestions, and tab completions that just work, with nothing to learn or configure.

If you use Homebrew, installing is simple:

# install fish
brew install fish

Homebrew will tell you what to do next:

# use fish
sudo echo /usr/local/bin/fish >> /etc/shells
chsh -s /usr/local/bin/fish

Once you have it working:

# learn fish
help

What’s to like

It includes the things I listed above out of the box. It also includes a few extra features I didn’t realise I would appreciate until I started using them.

Syntax highlighting

This isn’t just fancy wording for colour. This is colour that changes, and tells you things, as you type.

For example, If you you’ve typed an invalid command it displays as bold and red until corrected, saving you from the mild embarrassment of command not found

Autocomplete

As you are typing a command, fish will guess the command you want and display it after your curser in grey. Ignore it, or hit the right arrow to finish the command. I use this more than accessing the history or tabbing.

Documentation

I think if I can read a product’s documentation standing on one leg, on a train, on a 5 year old phone, and continue to enjoy myself, then it’s a win.

Seriously, run help.

Web based config

This is a weird one. Run fish_config and a web page will open allowing you to change colours, choose a preset prompt, view functions, delete history.

The range of preset prompts to choose from is just about right.

Settings are stored in ~/.config/fish/config.fish.

What’s the catch?

(see what I did there?)

It’s not POSIX compatible. This means that not everything that works in bash or zsh will work in fish.

Some of the syntax in fish is different to bash. It’s cleaner and a bit ruby-esque.

RVM

I use RVM to manage my ruby versions. It didn’t work straight away. The RVM site has some helpful information: https://rvm.io/integration/fish

This gist mentioned on the RVM site works best.
https://gist.github.com/eggegg/6077153

However, because of its cd trickery, RVM auto-switching still doesn’t work. This isn’t a major problem I get around it by switching manually rvm use ...

Or; I could switch to another ruby version manager. fry: a simple ruby version manager for fish

That random script you copied and pasted from stack overflow.

One day I tried to do something like this.

echo $(date +”%m_%d_%Y”)

then fish nicely yelled at me and told me how I could do better.

fish: Did you mean (COMMAND)? In fish, the ‘$’ character is only used for accessing variables. To learn more about command substitution in fish, type ‘help expand-command-substitution’.

Starting a bash session when you need it is easy enough. I think I’ve only reverted to that once.

Conclusion

I wouldn’t go installing fish everywhere, and I will continue write shell scripts for bash. However, for interactive everyday use, I think it’s a win.