From b6e84bbc991073f39287fd1242a222144a293ced Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 10 Dec 2025 09:32:14 +0100 Subject: [PATCH] zsh: Add fzf-tab manpage preview for commands If a command has a manpage associated, we now display it in the fzf-preview box that fzf-tab completion shows. --- terminal/.config/zsh/zshrc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/terminal/.config/zsh/zshrc b/terminal/.config/zsh/zshrc index cd73e71..9c4e4d2 100644 --- a/terminal/.config/zsh/zshrc +++ b/terminal/.config/zsh/zshrc @@ -94,8 +94,11 @@ zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath' # show systemd unit status zstyle ':fzf-tab:complete:systemctl-*:*' fzf-preview 'SYSTEMD_COLORS=1 systemctl status $word' # env var contents -zstyle ':fzf-tab:complete:(-command-|-parameter-|-brace-parameter-|export|unset|expand):*' \ +zstyle ':fzf-tab:complete:(-parameter-|-brace-parameter-|export|unset|expand):*' \ fzf-preview 'echo ${(P)word}' +# give MAN pages for cmds or show their expanded path +zstyle ':fzf-tab:complete:-command-:*' fzf-preview \ + '(out=$(tldr --color always "$word") 2>/dev/null && echo $out) || (out=$(MANWIDTH=$FZF_PREVIEW_COLUMNS man "$word") 2>/dev/null && echo $out) || (out=$(which "$word") && echo $out) || echo "${(P)word}"' # show hostname if we are in a distrobox environment if [ -n "$DISTROBOX_ENTER_PATH" ] && [ -f /run/.containerenv ]; then