ZSH is an extraordinary shell. I wrote about that some years ago. In order to make the zsh a little bit more beautiful I prefer installing oh-my-zsh or Powerlevel10k. In this article I want to introduce some plugins I can’t live without anymore.
Oh-My-ZSH
ohmyzsh can be easily installed using curl:
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
That’s it. ohmyzsh ships with plenty of different themes. The default theme is “robbyrussel”. I change that to “dallas” in ~/.zshrc:
ZSH_THEME="dallas"
..and source the config-file to change the theme:
source ~/.zshrc
My shell looks finally like that:
ZSH-Autosuggestions
Zsh-autosuggestions unobtrusively suggests commands as you type based on history and completions. We can install it by saving it to the zsh-plugins-directory:
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
After placing it into the plugins-directory we have to activate it by adding it to “plugins” in $HOME/.zshrc:
plugins=(git zsh-autosuggestions)
..and source the config-file to enable the plugin:
source ~/.zshrc
Now our shell suggests previous commands as we type. We can use the suggested command by pressing END
or by pressing the right arrow-key
ZSH-Syntax-Hightlighting
Zsh-syntax-highlighting indicates if the typed command has syntax errors. As with zsh-autosuggestions, zsh-syntax-highlighting must be placed into the zsh-plugins-directory:
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
Now we activate it by adding it to the plugins in $HOME/.zshrc:
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
..and source the config-file to enable the plugin:
source ~/.zshrc
Now our broken commands appear in red color and working commands in green:
FZF
fzf is a general-purpose command-line fuzzy finder. It enables fuzzy search when searching for previous commands or files. In order to install it we first download it using git:
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
cd ~/.fzf/
{21-02-16 9:33}pat:~/.fzf@master pt% ./install
Downloading bin/fzf ...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 635 100 635 0 0 17638 0 --:--:-- --:--:-- --:--:-- 17638
100 1122k 100 1122k 0 0 9434k 0 --:--:-- --:--:-- --:--:-- 9434k
- Checking fzf executable ... 0.25.1
Do you want to enable fuzzy auto-completion? ([y]/n)
Do you want to enable key bindings? ([y]/n)
Generate /home/pt/.fzf.bash ... OK
Generate /home/pt/.fzf.zsh ... OK
Do you want to update your shell configuration files? ([y]/n)
Update /home/pt/.bashrc:
- [ -f ~/.fzf.bash ] && source ~/.fzf.bash
+ Added
Update /home/pt/.zshrc:
- [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
+ Added
Finished. Restart your shell or reload config file.
source ~/.bashrc # bash
source ~/.zshrc # zsh
Use uninstall script to remove fzf.
For more information, see: https://github.com/junegunn/fzf
We can (re-)source the $HOME/.zshrc with source ~/.zshrc
in order to make it work. Now we can search files and directories using CTRL + t
and paste the selected onto the command-line:
Searching backwards in the zsh history can be done with CTRL + r
A fuzzy search for files can be performed with cat **<TAB>