My Linux Fish Shell Workflow
Tags: linux, fishshell
Published: 2021-10-18 10:27:31

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.

![Fish Shell Workflow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rbppfyn4krqxrxvp9b85.png)

## 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](https://github.com/jethrokuan/z). 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.
```fish
z portfolio
```
You can create the alias for that directory by going to that directory and then run
```fish
z <short-name-of-that-directory>
```
Now go back to your home directory and then run
```fish
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.

![Fish Shell Workflow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kox1c5pdjfb2q6xiyo0g.png)

## How to set it up?

So first we will install fish shell.
For mac users, 
```bash
brew install fish
```
For linux user, (chad users)
```bash
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,

```bash
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](https://github.com/jorgebucaran/fisher) is a package manager for fish shell and is very fast.
Install fisher by running,
```bash
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,
```bash
fisher install jethrokuan/z
```
Now you can create aliases for your directories and jump across them.

For the prompt, I use [Starship Prompt](https://starship.rs/). 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.
```bash
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](https://github.com/genzyy/dotfiles-v2/blob/main/config/starship.toml) or you can read the starship docs [here](https://starship.rs/config/#prompt).


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](https://github.com/jszczerbinsky/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!