DEV Community

Cover image for Easy way to fish shell
Pratham Sharma
Pratham Sharma

Posted on

Easy way to fish shell

So when I first started linux and went into command line it looked a bit ugly (yeah the bash prompt is ugly initially :p). So well I tried customizing it a bit. Soon after I got bored with bash and I heard about this new guy zsh and then I switched to zsh. And zsh was more powerful than bash cause it had a better completion and a better vi mode. I used oh-my-zsh for most of the time and for themes I went with default one. Besides I also used syntax highlight plugins and autocompletion plugin too. It was all working pretty fine but then I had to move to a new machine and soon I forgot how to install these plugins in zsh. I mean I could have googled but I am quite lazy so I got oh-my-zsh and that was it.

Fast forward to this week I picked this new shell called fish. This blog will be a brief intro to fish from perspective of a zsh/posix shell user.

So fish is a non posix shell which means that your bash scripts don't work here (most of them). Although almost all the unix commands work in fish so you don't have to worry about a missing command for most of time.

Now Some good features that you get in fish by default are auto-completion , auto-suggestion, syntax highlighting and it all works out of box

So let's talk about making fish usable. For example like using aliases and where is the config file?. So generally the config file for fish is in .config/fish/config.fish. You can open this file in any text editor u want.

Inside the file you can add all your configuration and functions like you do in zsh file. Ok what did I wanted to do ? Yeah alias. In fish shell there is nothing called alias rather it is called abbreviations. Abbreviations are almost similar to aliases. According fish's web site " Abbreviations are user-defined words that are replaced with longer phrases after they are entered. "
This means that abbreviations are somewhat similar to snippets. You type the initials and it automatically completes it. Which is wonderful because you get to see the command that you have abbreviated. To set abbreviations you can do abbr -a v nvim in your config.fish

v is the abbreviation and nvim is the completion for it. Also there are minor syntax differences in fish from zsh/posix. Honestly I think that fish's syntax can be called more a bit modernish. Nonetheless you can look at the syntax here .

There are plugins-managers like ohmyzsh available for fish too. Some of them are :

And maybe more I don't know all of them. I personally use fisher because it's quite easy.
For prompt's you have :

  • Tide I like tide cause it looks exactly similar to p10k and you can also configure it the same way from zsh. It's cool :p.
  • You can use others like shellder, and starship too.

Note : for nvm users fish does not support nvm instead u get this or something like this.

Here is my config
You can see the way my shell looks.
Working demo
It all get's completed with a spacebar :)

Yup so that's all about fish. I would really recommend fish to developers because of it's ease of use and setting up. If not using it forever atleast try giving fish a try.

Top comments (3)

Collapse
 
badasscoder profile image
Badasscoder

where is my config file

Collapse
 
ps173 profile image
Pratham Sharma

lol I don't have the config up and tidy. And I recently switched back to zsh. :)

Collapse
 
ps173 profile image
Pratham Sharma

But in case you want some good config here's one github.com/craftzdog/dotfiles-public