Skip to content

Previews & fzf-tab Contexts ​

zsh-fzf-unified provides previews across two layers: per-context zstyle ':fzf-tab:complete:...' rules for Tab completion, and the standalone zsh-fzf-unified-preview script shared by Ctrl-T, Alt-C, and Ctrl-G.

fzf-tab Completion Contexts ​

ContextPreview
cd, zDirectory contents (eza -1 --color=always --icons=always, else ls -1G on macOS / ls -1 --color=always on Linux)
env, exportCurrent variable value (${(P)word})
unsetFunction definition (whence -f) if it is a function, else current variable value
unaliasAlias definition (alias "$word")
kill, killall, pkillNumeric PID → ps -p "$word" -o pid,ppid,%cpu,%mem,user,comm --no-headers; name → pgrep -af "$word" | head -20
sshResolved config (ssh -G "$word" filtering hostname/user/port/identityfile/proxyjump), else dig +short "$word" | head -5
git-checkoutgit show --color=always --stat --oneline "$word" | head -60
git-diff, git-show, git-loggit show --color=always "$word" | head -200
o, oooconfSubcommand/flag descriptions (deps, secrets, subcommands) with --height=45% --layout=reverse --border=top, show-group full, query-string input
-command-tldr --color=always "$word", falling back to man "$word"
Everything else (*)Directory (eza/ls), image (chafa when wezterm is present), archive (7z l), text (bat capped at :500, else cat), or "System Context: $word"

Shared Content Preview (zsh-fzf-unified-preview) ​

Used by Ctrl-T (files/dirs), Alt-C (cd directories), and Ctrl-G (rg grep matches). Modeled after junegunn/fzf's bin/fzf-preview.sh:

Target TypePreview Behavior
FILENAME:LINENOResolves file and centers bat / batcat with --highlight-line on the matching line (used by Ctrl-G)
SymlinkPrints symlink -> <target> (or Broken symlink: <name> -> <target>) and previews the resolved target
DirectoryShows git status --short --branch (up to 40 lines) if inside a git repo, followed by eza, tree -C -L 1, or ls
Image (image/*)Uses kitten icat (inside Kitty or Ghostty), else chafa -s "$dim", else imgcat (iTerm2), sized to $FZF_PREVIEW_COLUMNS x $FZF_PREVIEW_LINES
Archive (zip, tar, bz2, gz, 7z, rar)Lists contents with 7z l
TextHighlighted via bat or batcat (--style="${BAT_STYLE:-numbers}", capped at 500 lines), else cat
Binary (*binary* MIME)Shows file summary plus a hex dump (xxd -l 256, else od -A x -t x1z | head -24)

Released under the MIT License.