Rishit Pandey
Posted on October 18, 2021
Hey Everyone!, I will be sharing my fish shell workflow on linux and how to set it up for your productivity boost.
Let's get started!
A little about fish shell
So you know about bash and zsh and how they work right? The fish shell is not like those shells. I mean they kinda have similarities but they do differ very much. ZSH can execute bash commands in a native as bash does but fish shell requires some editing to it specially when it comes to setting variables and exporting paths.
What's my workflow?
I usually work on the terminals only and for that I frequent switch between different directories, editing them in vim (I use neovim), etc. So for me having a built-in autocompletion for shell with syntax highlighting and is a plus point.
With that I also use this. This is a fish shell tool for jumping different directories with two word command.
For example, I have a very nested directory that I want to visit and from there I need to go to another nested directory and let's name the first directory as portfolio
and my terminal config
. Now for that I use the z
tool and using the z tool I can create aliases for that directory.
z portfolio
You can create the alias for that directory by going to that directory and then run
z <short-name-of-that-directory>
Now go back to your home directory and then run
z <name-of-that-directory>
and whoosh! you are straight into that directory.
Now I know some of you will say that we can create aliases in the shell itself but for that you have to go to its config file and then add that alias and the source the config file for every directory. Z tool helps to create aliases on the fly.
For the fish prompt, I use starship cross-platform shell prompt. Its very minimal and easy to use with all the information you need for the directory is being displayed on your terminal in a very minimal way.
How to set it up?
So first we will install fish shell.
For mac users,
brew install fish
For linux user, (chad users)
sudo pacman -S fish
sudo dnf install fish
sudo apt install fish
Once the shell is installed, we will change the default shell for the user,
chsh -S /usr/bin/fish
If you just want to try out the fish shell, you can enter into fish shell just by running fish
in your terminal.
Then we need to install a package manager for fish shell. The name is fisher
. Fisher is a package manager for fish shell and is very fast.
Install fisher by running,
curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher
Now the package manager is installed we can move on to installing and customizing the shell.
Add tools and Customize your shell!
First we will install z tool. Using fisher we can run,
fisher install jethrokuan/z
Now you can create aliases for your directories and jump across them.
For the prompt, I use Starship Prompt. For installing this I had some problem while running the below command in fish so I went to bash shell and executed the command and it installed the prompt successfully.
sh -c "$(curl -fsSL https://starship.rs/install.sh)"
The problem I faced was because of the different syntax that fish uses in contrast of what bash and zsh use.
Now you can also customize the prompt itself using a config file. I have my config here or you can read the starship docs here.
Thats it! Enjoy with your new terminal friend.
Extras
- You can also use tide which is powerlevel10k for fish and is much more customizable too.
- Also for icon support in the terminal while displaying directories, you can visit ptSh and exa.
Thanks for taking time to read and I appreciate your interest in my blog. This is my first blog so feel free to point out the mistakes and I will surely learn from them!
Posted on October 18, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.