How to Install & Use Zsh Autosuggestions Plugin

small example of auto-suggestions using "suto apt install something"

Zsh (or Z shell) is a Unix-based shell that significantly improves your scripting experience. Because of plugin support, it is way more customizable than other shell tools. Zsh offers a more dynamic display that makes it easier to go through the script and find the information you’re looking for. In terms of time to run a script, Zsh proved to be faster than Bash.

Using the community-supported framework Oh My Zsh, users can install various plugins and themes to further enhance the tool and modify it according to their needs.

One of these plugins is the Zsh AutoSuggestions plugin. As you type in the Zsh shell, this plugin will suggest commands based on your history and command execution.

Seasoned coders are familiar with how hectic it can get to type repeating commands again and again. This plugin will save ample time by suggesting commands based on the execution history. By just tapping a single key you will be able to enter your desired command if you’ve executed it before.


In order to install and use the Zsh autosuggestions plugins, you must have:

  • Zsh installed on your system. To do this you can use our tutorial on How to Install Zsh on Linux. Zsh is a Unix-based scripting shell.
  • Oh My Zsh installed on your system. You can achieve this using our tutorial on Installing Oh My Zsh on Linux.
  • Git installed on your system. We’ll quickly cover how to install it on Debian/Ubuntu-based systems or RHEL-based systems:
    • On Debian/Ubuntu-based systems run:
      sudo apt update
      sudo apt install git
    • On RHEL-based systems run:
      sudo dnf update
      sudo dnf install git

Assuming you have fulfilled all the prerequisites, you can install and use the autosuggestions plugin for Zsh.

Install Zsh AutoSuggestions Plugin

In order to use the Zsh autosuggestion plugin, we are going to have to install it and then enable it from the ~/.zshrc file.

To install the zsh-autosuggestions plugin via Oh My Zsh GitHub we need to clone the git repository to the plugins directory. Execute the command stated below to do this.

git clone ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

This will add the autosuggestion plugin repository to the plugins directory. Now all that is left for us to do is to enable the plugin from the ~/.zshrc file that contains all the configurations that will run when the Zsh shell is started.

You can open the ~/.zshrc file in any text editor of your choice. We are using the nano text editor to edit the ~/.zshrc file by executing the below line.

nano .zshrc

Above command will open the ~/.zshrc file. Scroll down in the file and locate the plugins section. Refer to the image below to see what the plugins section looks like in the ~/.zshrc file.

word image 11809 1

Edit the above text as shown below and add plugins=( zsh-autosuggestions) below the plugins option to enable the autosuggestions plugin.

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
source $ZSH/

Now press Ctrl + X to exit the file. Press Y and hit Enter to save the changes and exit.

The Zsh autosuggestions plugin has been installed. Close the terminal and by pressing Ctrl+D and run it again. You will see that autosuggestions are up and running.

Using Autosuggestions

Using the Autosuggestions plugin is very simple. After the plugin has been added and enabled, whenever you type in the terminal the plugin will suggest a completed command after the cursor in a grey color.

To accept the suggestions simply enter the right-arrow () key and the plugin will replace the entered command with the suggested command. To ignore the suggested command you can press the down-arrow () key or you can ignore the suggested command and keep typing. This is further demonstrated below.

word image 11809 2

This is how easy it is to use the autosuggestions plugin on Zsh.


This tutorial was about how to install and use the autosuggestion plugin for Zsh. The most important step is to add the plugin to the list of enabled plugins in the ~/.zshrc file so that it starts working. We also took a brief look at how to use the auto-suggestion plugin once it has been installed.

Notify of
Receive notifications when your comment receives a reply. (Optional)
Your username will link to your website. (Optional)

Inline Feedbacks
View all comments
You May Also Like