Skip to content

Instantly share code, notes, and snippets.

@burke
Last active December 11, 2015 06:18
Show Gist options
  • Save burke/4558106 to your computer and use it in GitHub Desktop.
Save burke/4558106 to your computer and use it in GitHub Desktop.

Fish

Installing Fish

Homebrew didn't work last time I tried. You might have better luck:

brew install fish

Otherwise:

git clone git://github.com/fish-shell/fish-shell.git
cd fish-shell
autoconf && ./configure && make && make install

Then, to set it as your default shell:

sudo sh
echo "/usr/local/bin/fish" >> /etc/shells
exit
chsh -s /usr/local/bin/fish

Cool things about fish

  • Colouring. Executables and Functions are blue, arguments are cyan, errors are red, and more.

  • Always in reverse-incremental-search mode

  • Completes pathnames, executables, and options from manpages.

Differences between fish and POSIX shells

Setting environment variables is very different.

# bash
export RAILS_ENV=test
# fish
set -x RAILS_ENV test

#bash
RAILS_ENV=test rake ...
# fish
set RAILS_ENV test ; rake ...

# bash
unset RAILS_ENV
# fish
set -e RAILS_ENV

Fish also has Universal environment variables. These are synchronized automatically between all running fish sessions on a machine. To use these:

set -Ux VAR value
set -Ue VAR

Control structures are somewhat different too:

# bash
for i in *; do echo $i; done
# fish
for i in *; echo $i; end

# bash
if [ 1 ] ; then echo hi ; fi
# fish
if [ 1 ] ; echo hi ; end

Subshells too:

# bash
for i in `ls foo` ; ...
for i in $(ls foo) ; ...
# fish
for i in (ls foo) ; ...

And && and || don't exist:

# bash
autoconf && ./configure
# fish
autoconf ; and ./configure

# bash
make || do_failed
# fish
make ; or do_failed

More features of fish

Aliases are functions in fish. You can edit them live with the funced funcname command, and save them to ~/.config/fish/functions -- which is preloaded on shell init -- by using funcsave functionname.

fish_config shows a goofy web configuration thing that I don't have much use for.

rbenv / rvm

RVM integration for fish

Or add this to ~/.config/fish/config.fish for rbenv.

set PATH $HOME/.rbenv/shims $PATH
set PATH $HOME/.rbenv/bin $PATH
rbenv rehash >/dev/null ^&1

See my config

@Zelnox
Copy link

Zelnox commented Feb 19, 2013

There’s fishfish on Homebrew now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment