Easy way to fish shell
Tags: linux, tooling, shell, configs
Published: 2021-07-13 17:46:59

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](https://fishshell.com/docs/current/tutorial.html) . 

There are plugins-managers like ohmyzsh available for fish too. Some of them are :   
- [ohmyfish](https://github.com/oh-my-fish/oh-my-fish)
- [fisher](https://github.com/jorgebucaran/fisher)

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](https://github.com/IlanCosman/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](https://github.com/simnalamburt/shellder), and [starship](https://starship.rs/) too. 

Note : for nvm users fish does not support nvm instead u get [this](https://github.com/jorgebucaran/nvm.fish) or something like [this](https://github.com/FabioAntunes/fish-nvm). 

![Here is my config](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5zjq7c4m10qeiew0pd39.png)
You can see the way my shell looks. 
![Working demo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rozs3s8odvjfefty6czc.gif)
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.