Scripts2026年5月17日·1 分钟阅读

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.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
zsh-autosuggestions Overview
通用 CLI 安装命令
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

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产