Introduction
Most of GNU/Linux distros use bash as the default terminal shell. But there are many aftermarket alternatives of cli shell for it. And my favourite is fish, the friendly interactive shell. Some of my favourite features of fish are:
- Command suggestion, usually based on history. Hit right arrow or Ctrl+F to complete it.
- Tab autocompletion, type several letter then hit Tab several times to see the options.
Hit enter to choose it.
- Syntax highlighting.
- Error telling, the part which containing any error will be pointed with caret symbol.
- Wildcard anywhere, but this is a double edge sword. Sometimes my literal question-mark is treaten as wildcard. So, I need to put a couple quote.
- Alt Navigation, hit Alt+Left/Right to go to previous/next directory. Like in the web browser or file manager.
- And many others. I replace oh-my-zsh with fish because it provides every feature I need from oh-my-zsh but still minimal & no need to install additional plugin.
Installation
Fish is available on most ditros official repository. I personally use Debian, so the command to install it is
|
|
Then set is as the default shell
|
|
After you launch a new shell session or open a new terminal, the default shell for your user will be fish. Maybe logout & login again is needed.
Configurations
Fish is pretty usable out of the box, but it looks ugly. So, we need to configure it first. The fish configuration file is stored in ~/.config/fish/functions/fish_prompt.fish. In case you wonder with my fish configuration, here is it. Beside eye candy, I also add more functionality. Like some useful alias, hightlight the background selection when cycling it with Tab button (there is no clue of selected item by default), hiding the annoying greeting message, and some other coloring options for accesbility.
|
|
On the left shell prompt, I only put the current working directory. I don’t need the username and host information, because I only use this machine locally & only have one user. On the right shell prompt I add a clock to measure how long a command is executed. I set the hightlight of command that’s not available in the system (which means error) to yellow to avoid typo. Maybe my fish configuration is not suitable for you. So, I recommend you to modify it to make it suit with your taste.
Note
Fish is not POSIX compliance like bash, zsh, or dash.
And I’m too lazy too learn fish scripting.
So, I’m still using bash as scripting shell.
To make my shell scripts interpreted by bash instead of fish,
I always add #!/bin/bash
on the line number one in every script.
But no need to worry, almost every shell script you get from the internet
are always shipped with shebang by default.
Thanks for reading!