Mild-Mannered Canadian Fury

Doug Stephen is Politely Peeved

Fishfish, a Fork of the fish shell

Wed, 06 Jun 2012 «permalink»


Fishfish (which really wants to be known as just fish) is a fork of the defunct and no longer maintained fish shell. It provides a lot of interactivity, such as IDE-like completions, “syntax” highlighting, and a bunch of other tools that make using the command line much less stressful.

It’s not a direct drop-in replacement for bash; while many of the commands may be extremely similar it uses a different configuration file and some of its conventions don’t match one to one (environment variables being the big one). This means that you can’t just copy the contents of your current .bashrc, .profile, .bash_profile, or whatever you’re using. It takes some work to get up and running with fish if you want to use it as your default log-in shell, especially if your startup configuration dotfile is complicated. I’m now running the fishfish fork of fish on both my work computer and my MBP.

A big pro tip, setting your PATH variable is a much different affair on fish. I’ll actually touch on this, if only because getting your PATH set up is one of the most important parts of any shell for a developer and the rest can fall in to place as you get more comfortable with fish:

  1. The location for user-specific shell configurations for fish should be stored in ~/.config/fish/ There are other places you can place startup commands at different levels of generic-ness or permission level, you can check out the documentation for more info.
  2. export is gone. fish uses set to modify environment variables by using key-value pairs that maps the variable to an array of values. fish arrays are base 1 indexed. Setting a variable with the -x option exports this variable to child processes. Let’s take a look at prepending /usr/local/bin and /usr/local/sbin to the front of the shell PATH variable. This is a common task in OS X for people who want use self compiled or packaged tools instead of the ones provided by the OS (think Ruby or Python, since Apple is usually slow to update these). Apple respects the Filesystem Hierarchy Standard in that it won’t touch /usr/local during updates or general system action, so /usr/local/bin is just as safe here as it is on any other \*NIX.

    In bash:
    Prepending /usr/local to the bash PATH variable, a common task in OS X
    export PATH="/usr/local/bin:/usr/local/sbin:$PATH"

    And in fish:
    Prepending /usr/local to the fish PATH variable and setting its export flag
    set -x PATH /usr/local/bin /usr/local/sbin $PATH

  3. fish doesn’t play very well with bad arguments, but it is angry in a very general and broad sense. Where this would normally be perfectly logical, it gets to be a pain when you want to do something like set up your environment variables. Neither /usr/local/bin nor /usr/local/sbin exist by default on an OS X install. Unless you add those directories yourself to do some custom compiles or you are a homebrew user, you probably won’t have those directories. But it’s common practice for a lot of PATH variables to be pre-filled with directories that don’t exist yet but may exist in the future. This sort of thing usually just gets ignored when the OS starts looking for commands entered at the shell prompt, but in fish this will cause the entire set statement to fail.

Armed with that little bit of knowledge, you’re set to take a look at fish and see if it fits your needs. Happy… shell-ing!