# ZSH Autocompletion

*January 2, 2025*
 — by Flaviu Vlaicu

> ZSH Autocompletion



# Enabling Command Autocompletion in ZSH

This guide will help you enable command autocomplete in Zsh using the zsh-autosuggestions plugin. Follow the steps below to get started, and if any issues arise,  refer to the troubleshooting tips to help resolve common problems.

## Prerequisites

- Ensure you have Oh My Zsh
  installed. This helps manage plugins and customize your Zsh experience.
- If you’re on macOS, Zsh is likely installed by default, but you may need to install Oh My Zsh
  separately.

### To install Oh My Zsh:

```bash {class="my-class" id="my-codeblock" lineNos=inline tabWidth=2}
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
```

### Step 1: Update Your .zshrc file

Add zsh-autosuggestions to the plugins array in your .zshrc file to enable it:

![Some Text](/images/2025-01/zsh-autosuggestions.jpg)

Once done, run source ~/.zshrc
If autocomplete suggestions work, you’re all set! If you see an error like this:

```bash {class="my-class" id="my-codeblock" lineNos=inline tabWidth=2}
[oh-my-zsh] plugin 'zsh-autosuggestions' not found
```

then zsh-autosuggestions might not be installed in the correct location. Continue to the troubleshooting steps below.

### Step 2: Troubleshooting: Plugin Not Found

If you encounter the “plugin not found” error, you likely need to install zsh-autosuggestions.  Follow these steps to manually install it.
For Both Linux and macOS Users:

- Clone zsh-autosuggestions into the Oh My Zsh custom plugins directory:

```bash {class="my-class" id="my-codeblock" lineNos=inline tabWidth=2}
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
```

Verify the plugins array in .zshrc: Ensure zsh-autosuggestions is still listed in your plugins:

```bash {class="my-class" id="my-codeblock" lineNos=inline tabWidth=2}
plugins=(
  git
  zsh-autosuggestions
)
```

Reload the configuration:

```bash {class="my-class" id="my-codeblock" lineNos=inline tabWidth=2}
source ~/.zshrc
```

This should resolve the vast majority of any errors you might see.

### Conclusion

By following these steps, you should now have zsh-autosuggestions enabled, and command autocomplete suggestions will appear as you type.  If you have any other questions or run into issues not covered here,  feel free to reach out in the comments!




---
*Source: [https://vlaicu.io/posts/zsh-autocompletion/](https://vlaicu.io/posts/zsh-autocompletion/)*
