Install zsh-autosuggestions using Antigen
masterTo install using the Antigen plugin manager, add the following line to your .zshrc file and then start a new terminal session.
antigen bundle zsh-users/zsh-autosuggestionsrepository·master·Indexed 12 days ago
https://github.com/zsh-users/zsh-autosuggestionsA Zsh plugin providing Fish-shell-like fast and unobtrusive autosuggestions based on command history and the completion engine. Requires Zsh v4.3.11 or later. Features include configurable suggestion strategies (history, completion, match_prev_cmd), asynchronous mode for Zsh 5.0.8+, and customizable highlight styles via ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE.
To install using the Antigen plugin manager, add the following line to your .zshrc file and then start a new terminal session.
antigen bundle zsh-users/zsh-autosuggestions~/.zsh/zsh-autosuggestions):git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions.zshrc file:source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zshgit clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
# Add to ~/.zshrc
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zshbrew install zsh-autosuggestions.zshrc file:source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zshbrew install zsh-autosuggestions
# Add to ~/.zshrc
source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zshTo use this plugin with Oh My Zsh, follow these steps:
~/.oh-my-zsh/custom/plugins):git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestionszsh-autosuggestions to your plugins array in your .zshrc file.git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# In ~/.zshrc
plugins=(
# other plugins...
zsh-autosuggestions
)As you type commands, suggestions appear after the cursor in a muted color.
<kbd>→</kbd> key (forward-char widget) or <kbd>End</kbd> (end-of-line widget) when the cursor is at the end of the buffer.forward-word widget to accept the suggestion up to the point where the cursor moves.To remove the plugin:
~/.zshrc.rm -rf ~/.zsh/zsh-autosuggestionsBy default, the plugin re-binds widgets on every precmd. To disable this and boost performance, set ZSH_AUTOSUGGEST_MANUAL_REBIND to any value.
Warning: If you do this, you must manually call _zsh_autosuggest_bind_widgets if you change widget lists or if other plugins wrap autosuggest widgets.
The ZSH_AUTOSUGGEST_STRATEGY array defines the order in which suggestion engines are tried. The plugin uses the first strategy that returns a match.
Available strategies:
history: Most recent match from command history.completion: Suggestion based on tab-completion (requires zpty module).match_prev_cmd: Most recent match whose preceding history item matches the most recently executed command.ZSH_AUTOSUGGEST_STRATEGY=(history completion)Suggestions are fetched asynchronously by default in Zsh 5.0.8+.
unset ZSH_AUTOSUGGEST_USE_ASYNC after sourcing the plugin.ZSH_AUTOSUGGEST_USE_ASYNC to any value after sourcing the plugin.You can control how the plugin interacts with Zsh Line Editor (ZLE) widgets by adding or removing them from these arrays:
ZSH_AUTOSUGGEST_CLEAR_WIDGETS: Clears the suggestion.ZSH_AUTOSUGGEST_ACCEPT_WIDGETS: Accepts the suggestion.ZSH_AUTOSUGGEST_EXECUTE_WIDGETS: Executes the suggestion.ZSH_AUTOSUGGEST_PARTIAL_ACCEPT_WIDGETS: Partially accepts the suggestion.ZSH_AUTOSUGGEST_IGNORE_WIDGETS: Prevents the plugin from triggering any behavior.Use ZSH_AUTOSUGGEST_HISTORY with a glob pattern to prevent the history and match_prev_cmd strategies from suggesting specific commands.
# Never suggest 'cd' commands
ZSH_AUTOSUGGEST_HISTORY="cd *"
# Never suggest anything 50 characters or longer
ZSH_AUTOSUGGEST_HISTORY="?(#c50,)"