Speed Up Your Terminal with zsh-autosuggestions in Oh My Zsh
Learn how to install and configure the third-party zsh-autosuggestions plugin with Oh My Zsh, a concrete git checkout example, customization options, and the trade-offs to watch.
25 Sept 2025, 10:16 UTC

The problem: repetitive typing slows you down
Every developer knows the friction of re‑typing long commands—git checkout feature/auth-refactor, docker compose up -d --build, or a lengthy kubectl invocation. Tab completion helps, but it only completes the current word. What if the shell could suggest the entire next command based on what you've run before?
What zsh-autosuggestions actually is
Despite the name, zsh-autosuggestions is not bundled with Oh My Zsh. It's a third-party plugin maintained by the zsh-users organization. To use it with Oh My Zsh, you clone it into your custom plugins directory and reference it as zsh-autosuggestions in your plugins array.
The plugin works by querying your Zsh history asynchronously. When you type, it searches for the most recent command that starts with your current input and displays the remainder as dimmed "ghost" text. Accepting the suggestion is a single keystroke (by default the right‑arrow key). The suggestion engine uses Zsh's built-in history access and ZLE (Zsh Line Editor) widgets—no custom trie or precmd hook is involved.
Installing and enabling the plugin
- Clone the repository into your Oh My Zsh custom plugins directory (requires write permission to your home directory):
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions - Open your
~/.zshrcand addzsh-autosuggestionsto thepluginsarray, e.g.:
plugins=(git docker zsh-autosuggestions) - Reload the configuration:
source ~/.zshrc
No additional dependencies are required beyond a standard Zsh installation (Zsh 5.3+ recommended). The plugin works with the default Oh My Zsh setup.
Worked example
Assume you have previously run:
git checkout feature/auth-refactor
Now start a new command line and type:
git co
You should see a dim suggestion appear: git checkout feature/auth-refactor. Press → (right arrow) to accept it; the full command is inserted and the cursor moves to the end, ready for Enter.
If you prefer a different acceptance key, bind it in ~/.zshrc after sourcing Oh My Zsh:
bindkey '^[[Z' autosuggest-accept # Shift‑Tab, for example
Customising the look
The ghost text colour is controlled by ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE. A common choice that works on both light and dark terminals:
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=8"
Place the export before the source $ZSH/oh-my-zsh.sh line so the plugin reads it at load time. Other useful variables include ZSH_AUTOSUGGEST_STRATEGY (default history; can be completion or an array) and ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE to limit suggestion length.
Trade‑offs and limitations
- Startup impact: The plugin adds some overhead during shell initialization because it loads the history and sets up ZLE widgets. With many plugins enabled, you may notice a slight increase in startup time. If latency matters, consider lazy-loading with a tool like
zsh-deferor trimming rarely used plugins. - Key‑binding conflicts: The default acceptance key (right arrow) may clash with custom vi‑mode bindings or other widgets. Verify your
bindkeymap or choose an alternate key as shown above. - History quality matters: Suggestions are drawn from the most recent matching history entry. If your history contains similar but divergent commands (e.g.,
git commit -m "fix"vsgit commit -m "feat"), the ghost text may be misleading—always glance before accepting. - Non‑interactive shells: The plugin automatically disables itself in non-interactive contexts (it checks
[[ -o interactive ]]), so CI pipelines and cron jobs are unaffected. - No
unsetopt autosuggest: There is no such Zsh option. To disable the plugin, removezsh-autosuggestionsfrom thepluginsarray and reload, or unset the widget withzle -D autosuggest-acceptin your config.
Quick verification checklist
- After editing
~/.zshrc, runsource ~/.zshrc(or open a new terminal). - Type a prefix you know exists in history (e.g.,
docker co) and confirm the dim suggestion appears. - Press the acceptance key; the full command should be inserted without extra characters.
- To test isolation, start a clean Zsh without Oh My Zsh:
zsh -f, then source only the plugin file (source ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh) and repeat step 2. - Disable the plugin by removing it from the
pluginsarray, reload, and verify that no ghost text appears.
If all steps behave as described, the plugin is correctly integrated.
Next steps
Clone zsh-autosuggestions into your custom plugins directory today and add it to your plugins array. Tweak ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE to match your theme. Monitor shell startup time for a week; if it becomes noticeable, explore lazy loading or prune rarely used plugins. The payoff—fewer keystrokes on every repetitive command—compounds quickly across a typical development day.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.