# zsh-autosuggestions

> Zsh plugin that shows inline command suggestions after the cursor, drawn from history and tab-completion, in the style of Fish.

Stars: 36.2k · Language: Shell · License: MIT · Categories: Shell

- Repository: https://github.com/zsh-users/zsh-autosuggestions
- Page: https://www.trmn.sh/tools/zsh-autosuggestions

## Overview

zsh-autosuggestions is a plugin for the Z shell that displays a suggested completion after the cursor as you type a command. The suggestion appears in muted gray by default (`fg=8`) and is based on command history and completions, similar to the autosuggestion behavior in Fish. It requires Zsh v4.3.11 or later.

Pressing the right arrow (`forward-char`) or End (`end-of-line`) with the cursor at the end of the buffer accepts the suggestion. Invoking `forward-word` accepts it partially, up to where the cursor moves. Suggestions are generated by a configurable `ZSH_AUTOSUGGEST_STRATEGY` array, whose entries are tried in order until one returns a match. The built-in strategies are `history` (most recent match), `completion` (what tab-completion would suggest, using the `zpty` module), and `match_prev_cmd` (the most recent history match whose preceding entry matches the last executed command).

Behavior is controlled through environment variables. You can change the highlight style with `ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE`, and cap buffer size with `ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE`. `ZSH_AUTOSUGGEST_HISTORY_IGNORE` and `ZSH_AUTOSUGGEST_COMPLETION_IGNORE` take glob patterns to filter out suggestions. Zle widget behavior is remapped through the `ZSH_AUTOSUGGEST_*_WIDGETS` arrays (clear, accept, execute, partial accept, ignore). Suggestions are fetched asynchronously by default on zsh 5.0.8 and later. Automatic widget re-binding can be turned off with `ZSH_AUTOSUGGEST_MANUAL_REBIND` for better performance.

The plugin also provides widgets for `bindkey`: `autosuggest-accept`, `autosuggest-execute`, `autosuggest-clear`, `autosuggest-fetch`, `autosuggest-disable`, `autosuggest-enable`, and `autosuggest-toggle`. It is aimed at zsh users who want history-based completion on the command line, including Oh My Zsh users, who can put the configuration in `$ZSH_CUSTOM`.

![zsh-autosuggestions demo recording](https://media.trmn.sh/cached/810064c9ca889cf4e374a4091c0d88bc23d91abbfca42a2a5524caa6a1286d0a.png)

## Alternatives

- [Spaceship Prompt](https://www.trmn.sh/tools/spaceship-prompt.md): Customizable Zsh prompt that shows Git/Mercurial status, language runtime versions, Docker, Kubernetes, battery and more, with support for custom sections. (Shell, 20.6k stars)
- [Powerlevel10k](https://www.trmn.sh/tools/powerlevel10k.md): Zsh prompt theme with an interactive configuration wizard, instant prompt at shell startup, Git status segments, and Powerlevel9k config compatibility. (Shell, 55.3k stars)
- [tpm](https://www.trmn.sh/tools/tpm.md): Tmux Plugin Manager: installs, updates, and removes tmux plugins from GitHub or other git repositories, configured via ~/.tmux.conf. (Shell, 15.1k stars)
- [Pure](https://www.trmn.sh/tools/pure.md): ZSH prompt that shows git branch, dirty state, and async-checked unpushed/unpulled arrows, with exit-status coloring and command execution time. (Shell, 14.5k stars)
- [Oh My Zsh](https://www.trmn.sh/tools/ohmyzsh.md): Community-maintained framework for managing zsh configuration, with 300+ plugins, 140+ themes, and a built-in updater. (Shell, 190.2k stars)

---

Canonical: https://www.trmn.sh/tools/zsh-autosuggestions
