How to setup and configure autocomplete on ZSH

If you are a one-time terminal user, you can use the default shell that comes with your system; it (Bash) has a wide range of functionalities and tools to help you accomplish your tasks. However, if you are a regular terminal user, Bash can get boring, repetitive, and inefficient.

This tutorial will show you how to set up a real-time, type-ahead autocompletion module for ZSH to make working with the terminal easier and more efficient.

Using zsh-autocomplete

The first method we shall use is the zsh-autocomplete repository, a simple shell script that enables real-time auto-completion and suggestions in your ZSH shell as you type.

Before installing it, ensure you have ZSH and git installed and up to date.

The first step is to clone the repository:

git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git

Next, remove any calls to compinit available in the ZSH config file then finally, navigate to the cloned repository and add the .zsh file to .zshrc using the source command:

cd zsh-autocomplete source

Once you have successfully installed the tool, you can now see auto-suggestions as you type commands:

Using zsh-autosuggestions

The other method is to use the zsh-autosuggestions package. This package allows you to auto-suggest commands based on your commands’ history, allowing you to access commonly used commands with ease.

Using apt package manager, issue the install as:

sudo apt-get update
sudo apt-get install zsh-autosuggestions -y

Once installed, you can start typing commands, and you will get access to the commands you can type in that context.


Using the two mentioned approaches, you can make your tasks in the shell much easier by quickly accessing previously used commands and new ones in real-time.

About the author

John Otieno

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list