Skip to content

feat: add fzf-tab completion groups for SSH config and known_hosts - #1

Draft
Elliot-32 wants to merge 9 commits into
masterfrom
feat/fzf-tab-completion-groups
Draft

Elliot-32 wants to merge 9 commits into
masterfrom
feat/fzf-tab-completion-groups

Conversation

@Elliot-32

@Elliot-32 Elliot-32 commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Summary

Expose SSH config aliases and known hosts as separate native completion groups for fzf-tab. When the current completion context has a non-empty descriptions format, both sources are offered automatically. Without that format, or with an explicit empty format, known hosts are included only when ZSH_SSH_INCLUDE_KNOWN_HOSTS=1. The standalone fzf interface also retains its opt-in for its combined list.

  • Preserve login prefixes and preceding SSH options: ssh -p 2222 root@prod<Tab> and ssh -vp2222 root@prod<Tab> complete only the destination. Option values and remote command arguments use native SSH completion. -F selects an alternate config and -F none skips config aliases.
  • Match both sources with the same hostname matcher, without pre-filtering config candidates through grep. For example, p.w completes to prod.web. tag: always filters config records only and is replaced by the selected alias, including with user@ or a cursor inside the query.
  • Share unstyled config records between native completion and the standalone UI. Restore aligned Alias, Hostname, User, optional Tag and Desc columns with a table heading in fzf-tab; only the alias is inserted. Known hostnames are deduplicated with a Zsh array.
  • Restore the right-hand ssh -T -G preview with User, HostName, Port, ControlMaster, ForwardAgent, LocalForward, IdentityFile, RemoteForward, ProxyCommand and ProxyJump. Preserve the selected login prefix, preceding SSH options, and config path. Preview arguments are quoted, including paths with spaces.
  • Provide preview and layout defaults through least-specific dynamic fzf-tab styles that activate only for SSH destinations. Existing global styles, explicit empty previews, and command-specific or later styles take precedence. Other commands, SSH option values and remote command arguments receive no SSH preview.
  • Register the source with compdef and defer the standalone Tab binding until the first prompt. Either plugin order works when both load before that prompt. Disabling fzf-tab leaves ordinary native completion, and re-enabling it restores its interface.
  • Document the known-host inclusion rules and fzf-tab settings: a description format enables group support, menu no is recommended, and changing group-switching keys is optional (defaults: F1/F2). The plugin does not modify those global styles.

Validation

  • FZF_TAB_DIR=/path/to/fzf-tab zsh -f tests/completion.zsh native fzf-first plugin-first: 148 checks passed on Zsh 5.9 / Windows MSYS2 with fzf-tab 24105b15714bfec37989ed5c5b6e60f572253019.
  • zsh -f tests/preview.zsh: 28 preview checks passed, using a fake SSH executable. Covers all preview fields, option/config propagation, paths with spaces, literal selected words, preservation of custom styles, and suppression outside SSH destination completion.
  • A real fzf 0.74.3 pseudo-terminal smoke test displayed the table heading, aligned columns, both group labels and the right-hand preview using fixture SSH output. The Windows test harness supplied an explicit Zsh path for the preview subprocess.
  • Completion coverage includes known-host opt-in rules for missing/empty/global/SSH-specific description formats, SSH argument routing, login prefixes, tag queries, cursor placement, Include files and deduplication.
  • Zsh syntax checks and git diff --cached --check passed. Standalone host-list formatting is unchanged by the display restoration.

The suite also includes compinit-after-loading and disable/re-enable modes. Group-switching keys and Linux/macOS were not exercised in this run; preview execution tests used a fake SSH executable and made no SSH connections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant