Autocomplete for Zsh
This plugin for Zsh adds real-time type-ahead autocompletion to your command line, similar to what you find in desktop apps. While you type on the command line, available completions are listed automatically; no need to press any keyboard shortcuts. Press Tab to insert the top completion or ↓ to select a different one.
Additional features:
- Out-of-the-box configuration of Zsh’s completion system
- Multi-line history search
- Completion of recent directories
- Useful keyboard shortcuts
- Easy to configure
Enjoy using this software? Become a sponsor! 💝
Requirements
Recommended:
- Tested to work with Zsh 5.8 and newer.
Minimum:
- Should theoretically work with Zsh 5.4, but I’m unable to test that.
Installation & setup
Note: In this manual,
%represents the command line prompt. If you see it in front of a command, it means you should run it on the command line, not put it in a script.
First, install Autocomplete itself. Here are some way to do so:
-
To use only releases (instead of the
mainbranch), installzsh-autocompletewith a package manager. As of this writing, this package is available through Homebrew, Nix,pacman, Plumage, and (asapp-shells/zsh-autocomplete) Portage. -
To always use the latest commit on the
mainbranch, do one of the following: -
Use
pacmanto installzsh-autocomplete-git. -
Use a Zsh plugin manager to install
marlonrichert/zsh-autocomplete. (If you don’t have a plugin manager yet, I recommend using Znap.) -
Clone the repo directly:
% git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git
After installing, make the following modifications to your shell config:
-
In your
.zshrcfile: -
Remove any calls to
compinit. -
Add near the top, before any calls to
compdef:
source /path/to/zsh-autocomplete/zsh-autocomplete.plugin.zsh
- When using Ubuntu, add to your
.zshenvfile:
skip_global_compinit=1
- When using Nix, add to your
home.nixfile:
programs.zsh.enableCompletion = false;
Finally, restart your shell. Here’s two ways to do so:
- Open a new tab or window in your terminal.
- Replace the current shell with a new one:
% exec zsh
Updating
If you installed manually, run:
% git -C ~autocomplete pull
Otherwise, simply use your package manager or plugin manager’s update mechanisms.
Uninstalling
- Revert the actions you took to install.
- Restart your shell.