loading...
Cover image for Why you should give a chance to Fish shell

Why you should give a chance to Fish shell

jukben profile image Jakub Benes Originally published at Medium Updated on ・3 min read

Probably, a lot of you already heard about Z-shell. It's particularly popular because of an awesome package Oh My Zsh. Within relatively easy installation you get fully fledged shell ready to work with a bunch of plugins already pre-installed and rest of it easily configurable. At least they say that.

I've used Zsh for many years yet I've recently tried another approach. During my latest hardware upgrade, I've tried to experiment and I've installed Fish shell. After one year I have to say that I'm not planning to go back and I'd like to encourage you to try it as well.

With Zsh you can do awesome things (check it out the article of my friend @satya164), there are packages for everything I would say. On the other hand, you have to pay price for that. Firstly you need to configure it, secondly, it could happen that your shell's startup time will be affected. Fish has chosen the different approach.

Let's take a look on this recording of my terminal. Just to get an idea what I'm talking about.

asciicast

Let's sum it up. You could have seen:

  • auto-suggestions
  • syntax highlighting
  • tab completions (like you have seen for yarn run in the recording above)

and all of it out of the box! Awesome, right?

How to install? (on 🍎)

  1. install Fish via Brew 🍺
  2. Add Fish to known shells
  3. Set default shell to Fish
brew install fish  
sudo echo /usr/local/bin/fish >> /etc/shells
chsh -s /usr/local/bin/fish

But what to do if you want some MOAR?

more

I would heavily recommend Fisher plugin manager for Fish shell. (If you are more into a framework – take a look on Oh My Fish)

Let's install it!

curl -Lo ~/.config/fish/functions/fisher.fish --create-dirs https://git.io/fisher

Now you are all set to install all the sweets you think of. Need some inspiration?

  1. Done - plugin to automatically receive notifications when long processes finish.
fisher add franciscolourenco/done
  1. Carp - my personalized theme :)
fisher add jukben/carp
  1. Z - Z script inside fish shell
brew install z
fisher add jukben/z
  1. fzf - useful fzf key bindings in fish
fisher add jethrokuan/fzf

So if you are still with me you might ask: "What's the catch?"

catch

Fish is not 100% POSIX compliant. Fish is how Wikipedia claims considered as "exotic shell". I love the scripting syntax, it also provides nice error complaints, which is always pretty useful. But what does it mean it in real life, right?

You might be used to use quite often command like this:

ENV=test yarn start

Unfortunately, fish will say

fish: Unsupported use of '='. To run 'yarn' with a modified environment, please use 'env ENV=test yarn…'

so as you have probably assumed correctly, you have to type

env ENV=test yarn start

It's not so terrible, right?

Another quite popular example is

yarn && yarn run

UPDATE: Fish 3.0 newly supports && and ||, so feel free to use whenever syntax you like.

Again, unfortunately, fish will say

fish: Unsupported use of '&&'. In fish, please use 'COMMAND; and COMMAND'.

so once you type

yarn; and yarn run

everything will be OK. I know that it could be a pain, especially from the beginning. But I hope you can make it through. And if cannot there is always the plugin for it™.

Bass - makes it easy to use utilities written for Bash in fish shell

fisher add edc/bass

Don't worry, all of your other utilities will be fine as soon they have correct Shebang e.g #!/bin/sh. For example, all NPM scripts (npm/yarn run ...) are run under sh as well, so you should type your commands as you're used to.

We made it! I hope you have enjoyed this article. If you like it or you have any question, please feel free to comment it below 👇.

P.S: You can check it out my dotfiles for the inspiration. Versioned with gbck tool what I made.

Discussion

pic
Editor guide
Collapse
moopet profile image
Ben Sinclair

I like that there're a lot of shells people can use, but I'm sticking with bash.

I quite like the autocompletion thing I guess, but I find it a little distracting to see the previous options for a command I used. If I want to recall a previous command, I'll usually just do ctrl-r and start typing. If I don't want to use the same arguments I used before, I don't want to see stuff come up under my cursor.

I could get by with the environment differences - though instead of doing ENV foo=bar command I'd probably do foo=bar; export foo; command which is almost the same thing and should work everywhere. If I'm going to have to adjust my syntax to get it to work in bash (which everyone and their dog has) I might as well make it work in as many shells as possible.

The lack of && is more of a problem. Don't like that at all!

I never liked oh-my-zsh, either.

Collapse
benyamins profile image
benyamins

Hey! Nice article, I just wanted to point out that as of version 3.0 fish supports && and || operators!

Collapse
jukben profile image
Jakub Benes Author

Thanks for letting me know, I've just updated the article.

Collapse
mexchip profile image
José Jorge

Some months ago I wanted to try another shell, my candidates were zsh and fish. I think fish is great, but I'm using zsh, mainly because of the better compatibility with bash.

Collapse
dallgoot profile image
dallgoot

no mention of Oh my fish ? ;)
github.com/oh-my-fish/oh-my-fish

Collapse
jukben profile image
Jakub Benes Author

I have to admit that I'm not a fan of this. I frankly think that the real power of fish is that you need only plugin manager - and Fisherman is fast and reliable. Anyway, I've added a link to the article. Thanks!