Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsMay 17, 2026·2 min de lecture

zsh-autosuggestions — Fish-Like Autosuggestions for Zsh

A Zsh plugin that suggests commands as you type based on history and completions, accepting suggestions with a single keystroke.

Prêt pour agents

Cet actif peut être lu et installé directement par les agents

TokRepo expose une commande CLI universelle, un contrat d'installation, le metadata JSON, un plan selon l'adaptateur et le contenu raw pour aider les agents à juger l'adaptation, le risque et les prochaines actions.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
zsh-autosuggestions Overview
Commande CLI universelle
npx tokrepo install 4431d30f-51eb-11f1-9bc6-00163e2b0d79

Introduction

zsh-autosuggestions brings Fish shell-style inline command suggestions to Zsh. As you type, it displays a grayed-out completion of the most likely command from your shell history, which you can accept with the right arrow key or end-of-line widget.

What zsh-autosuggestions Does

  • Displays inline suggestions based on command history as you type
  • Supports multiple suggestion strategies: history, completion, match_prev_cmd
  • Accepts full or partial suggestions with configurable key bindings
  • Updates suggestions in real-time with each keystroke
  • Integrates with Zsh completion system for context-aware suggestions

Architecture Overview

The plugin hooks into Zsh's ZLE (Zsh Line Editor) via precmd and preexec widgets. On each keypress, it queries the configured strategy (history file search by default) to find a matching prefix, then renders the suggestion as a ZLE buffer suffix with a dimmed color. Accepting the suggestion copies the suffix into the main buffer.

Self-Hosting & Configuration

  • Install via Oh My Zsh, Zinit, Zplug, Antigen, or Homebrew
  • Set ZSH_AUTOSUGGEST_STRATEGY=(history completion) for fallback ordering
  • Configure ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE to change suggestion color
  • Set ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE to skip suggestions on long lines
  • Bind partial accept with bindkey for word-by-word acceptance

Key Features

  • Zero-latency suggestions that never block interactive typing
  • Strategy stacking: try history first, fall back to completion engine
  • Async mode for expensive completion strategies without input lag
  • Works seamlessly with syntax highlighting and other ZLE plugins
  • Minimal resource usage with no background processes

Comparison with Similar Tools

  • Fish shell — has autosuggestions built-in but requires switching shells
  • zsh-autocomplete — more aggressive real-time completion menu approach
  • fzf tab completion — fuzzy matching in a menu rather than inline suggestions
  • Atuin — full history database with search UI, heavier than inline hints

FAQ

Q: How do I accept only part of a suggestion? A: Press Ctrl+Right arrow to accept word-by-word, or bind forward-word to your preferred key.

Q: Can suggestions come from something other than history? A: Yes, set ZSH_AUTOSUGGEST_STRATEGY=(completion) to use the Zsh completion system.

Q: Does it conflict with zsh-syntax-highlighting? A: No, they work together. Load syntax-highlighting before autosuggestions for best results.

Q: How do I change the suggestion text color? A: Set ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#808080" in your .zshrc.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires