Bash: the default shell preinstalled in most Linux distributions is rock solid and industry standard for many years. There is not much to complain about Bash. It does the job and is the default shell on almost all Linux distributions. All the Linux tutorials and blogs assume you are using Bash. However, there are other shells to explore, including the famous ZSH and Fish shells. However, Bash is not customizable as ZSH or Fish. The more you can customize your shell, the more you can tailor it for your needs and be productive.
Why not Fish?
Some time ago, I tried ZSH, but it was too slow to open. Spending more time to open the terminal than running the actual command didn't justify using ZSH. That's when I decided to try Fish. Though Fish offers even more customization than ZSH, it breaks compatibility with Bash. From simple export commands to complex Bash scripts won't work in Fish out of the box. Every time I copy-paste some CLI commands from a website, I had to change the syntax to Fish almost every time I copy commands from the internet. It defeats the purpose of Fish. I installed Fish to boost my productivity, but it was counterproductive when writing shell scripts.
Once again, I switched back to ZSH to give it a try. Surprisingly it is as snappy as Bash and Fish this time. The slowness of ZSH could come from an older version, an extension I used, or due to my years-old hardware. However, after installing ZSH with all the necessary plugins, it runs as smoothly as Bash without sacrificing the features I love in Fish.
Installing Zsh
Zsh is already available in the official repositories of all Linux
distributions.
Debian or Ubuntu-based:
sudo apt install zsh
Fedora:
sudo dnf install zsh
Arch:
sudo pacman -S zsh
Once installed, run the following commands to set it as your default terminal.
chsh -s $(which zsh)
Open a new Terminal and you will be welcomed by the Zsh configuration. Zsh requires new users to configure it before using it. I recommend Option 2: Populate your ~/.zshrc with the configuration recommended by the system administrator and exit because the Zsh Framework we are going to install next will override them anyway.
Zsh Framework
There are several other Zsh frameworks out there but I stop with these two frameworks to avoid getting into the rabbit hole of frameworks.
Configuration
As recommended earlier, I am also using Oh My Zsh. The following section introduces the Zsh plugins I use to boost my productivity.1. Oh My Zsh
NOTE: Oh My Zsh installer depends on git. Even after installing, you will need it to install the Zsh Plugins.
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Agnoster theme heavily relies on powerline fonts. Install the powerline fonts using the following command:
Debian or Ubuntu-based Linux distribution:
sudo apt install fonts-powerline
Fedora or Redhat based Linux distribution:
sudo dnf install powerline-fonts
Arch:
sudo pacman -S powerline powerline-fonts
Once the powerline font is installed, open the ~/.zshrc file and change the ZSH_THEME value to agnoster as shown below.
ZSH_THEME="agnoster"
For the awesome list of Zsh plugins, check this GitHub repository. Though there are hundreds of plugins, I need only three additional plugins to complete my Oh My Zsh experience.
3. Zsh Auto Suggestions
To install the plugin to Oh My Zsh, run the following command to download the plugin.
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
Edit the ~/.zshrc file and add zsh-autosuggestions to the plugins list as shown below.
plugins=(
git
zsh-autosuggestions)
Restart the terminal to get a new Zsh session.
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#474747"
You can also customize the background and font style if it doesn't align with your taste.
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ff00ff,bg=cyan,bold,underline"
4. Copypath
plugins=(
git
zsh-autosuggestions
copypath)
copypath
, and your current path will be
copied to the clipboard. You can paste it anywhere you want.5. Sudo
plugins=(
git
zsh-autosuggestions
sudo
copypath)
Tip
setopt no_share_history
unsetopt share_history
No comments
Post a Comment