██████╗ ██████╗ ███████╗████████╗███████╗ ██╔══██╗██╔═══██╗██╔════╝╚══██╔══╝██╔════╝ ██████╔╝██║ ██║███████╗ ██║ ███████╗ ██╔═══╝ ██║ ██║╚════██║ ██║ ╚════██║ ██║ ╚██████╔╝███████║ ██║ ███████║ ╚═╝ ╚═════╝ ╚══════╝ ╚═╝ ╚══════╝
I used to have fish
as my main shell for it's many useful features, such as the autosuggestion of past commands,
the syntax highlighting to show with colors if a command is valid or not and the easy shell configuration
through the Web-UI.
However, I still encountered some issues with fish. Namely, fish isn't compliant with the posix standard.
This means that it isn't compatible with specific shell standards, making my life harder trying to do specific things
that would be very easy to do with a POSIX compliant shell.
A good example for this would be setting an alias. If I wanted to set an alias in zsh, all I would have to do
is enter my .zshrc file with a text editor and enter something like "alias ls='ls --color -X -A'".
Meanwhile with fish I would have to go through a labyrinth of directories just to create an entire file for a single alias
using fish's obscure language.
And thus I chose zsh as a viable alternative due to the plugin support, its minimal nature and it being POSIX compliant which makes life much easier.
The plugins I will be talking about are for fish-like
autosuggestions and
syntax highlighting.
There are many different ways on how to install zsh plugins, with using a plugin manager like
Oh My Zsh being the most popular.
However, I think that would be a bit finicky and unnecessary, so in this guide I will being installing the plugins manually with the use of a terminal.
Firstly, we will create a directory to store our plugins in by executing:
$ mkdir ~/.zsh
Next, we are going to git clone the plugins into the directory we just made by executing the following commands:
$ cd ~/.zsh
$ git clone https://github.com/zsh-users/zsh-autosuggestions
$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
After doing that you'll have to link the plugins to your .zshrc file.
Be sure to add the following lines at the very bottom of your .zshrc file with your preferred text editor (I will be using neovim).
$ nvim ~/.zshrc
source ~/.zsh./zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
Since the autosuggestions plugin will only work within a single terminal session and the command history
will be reset after closing the terminal, you will have to add a few lines to your .zshrc which will keep a log file of your shell history
and will share that across multiple terminal sessions.
Put the following lines above the previous ones in your .zshrc file:
HISTSIZE=5000 #How many lines of history to save in RAM
HISTFILE=~/.zsh_history #Where to save history to disk
SAVEHIST=5000 #Number of history entries to save to disk
#HISTDUP=erase #Erase duplicates in the history file
setopt appendhistory #Append history to the history file
setopt sharehistory #Share history across terminals
setopt incappendhistory #Immediately append to the history file
Congratulations! If you followed all of those instructions then you should have a working zsh setup with fish-like features. You could also customize the history configuration and other aspects as well to better suite your needs. Now all there is to do is to test it out and enjoy it!
Thanks for reading my post, I hope you enjoyed it!
If you have any feedback or questions regarding this topic or post, feel free to
contact me
on Matrix, Discord or through Email.