This tutorial will teach you how to set up a ZSH shell and add features, such as command auto-suggestions.
Step 1 – Installing ZSH
The first step before adding shell extensions is to ensure you have ZSH. It is available in most major Linux distributions package managers.
To install it, use the following commands:
sudo apt-get install zsh
sudo yum install zsh
sudo pacman -S zsh
Once you have ZSH installed successfully, we can proceed to install the zsh-autosuggestions tool.
Step 2 – Changing Default Shell
After installing ZSH, it is good to make sure it is the default shell. This will prevent you from launching the ZSH shell when using your tool.
To confirm, enter the following command:
Step 3 – Enabling zsh-autosuggestions
After installing and setting up the ZSH shell, we can set up the zsh-autosuggestions plugin. Start by cloning the zsh-autosuggestions:
Finally, add the following command to your .zshrc file:
Using Oh-my-ZSH Framework
If you have the oh-my-zsh framework installed, you can use the auto-suggestions as a plugin. Start cloning the auto-suggestions repository using the following command:
Next, enable the plugin by adding the entry as shown below:
Import Bash History to ZSH
If you were using Bash as your default shell, you could import all your command history from the .bash_history file.
In this tutorial, we discussed how to set up a ZSH shell and the zsh-autosuggestions feature. It automatically provides suggestions for commands based on previous commands. Thus, making it easier for recurring commands.