From 69860d2e483c1ca4313aa6105cc8d782574359c9 Mon Sep 17 00:00:00 2001 From: Andrejus Date: Fri, 13 Mar 2026 17:16:49 +0000 Subject: [PATCH] feat(fzf): use preview script in all workflows Replace inline bat/head preview commands with the universal preview script in the f() alias, file picker, and grep picker. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- home/.aliases | 2 +- home/.zsh/widgets.zsh | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/home/.aliases b/home/.aliases index f52b72a..b0e130e 100644 --- a/home/.aliases +++ b/home/.aliases @@ -46,7 +46,7 @@ gdm() { local base="${1:-$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null # fzf workflows gb() { local b; b="$(git branch --all --sort=-committerdate --format='%(refname:short)' | fzf --preview 'git log --oneline --color -20 {}')" && git checkout "${b#origin/}"; } glo() { git log --oneline --color --decorate | fzf --ansi --preview 'git show --color --stat {1}' --bind 'enter:become(echo {1})'; } -f() { local f; f="$(fzf --preview 'head -100 {}')" && ${EDITOR:-vim} "$f"; } +f() { local f; f="$(fzf --preview 'preview {}')" && ${EDITOR:-vim} "$f"; } if [[ -z "${CODESPACES:-}" ]]; then ssh() { diff --git a/home/.zsh/widgets.zsh b/home/.zsh/widgets.zsh index 52e9163..bffb8bd 100644 --- a/home/.zsh/widgets.zsh +++ b/home/.zsh/widgets.zsh @@ -62,7 +62,9 @@ _dots_load_keybindings() { rg --files --hidden --glob '!.git' 2>/dev/null | awk '{print " \t" $0}' } | awk -F'\t' '!seen[$2]++' \ | fzf --ansi --delimiter='\t' --nth=2 \ - --preview 'bat --color=always --style=numbers --line-range=:100 {2} 2>/dev/null || head -100 {2}')" \ + --header 'enter=edit | ^v=preview' \ + --preview 'preview {2}' \ + --bind 'ctrl-v:execute(preview {2})')" \ || { zle reset-prompt; return; } file="$(printf '%s' "$file" | cut -f2)" [[ -z "$file" ]] && { zle reset-prompt; return; } @@ -117,7 +119,7 @@ _dots_load_keybindings() { local selection selection="$(rg --color=always --line-number --no-heading --hidden --glob '!.git' '' 2>/dev/null \ | fzf --ansi --delimiter=: \ - --preview 'n={2}; n=${n:-1}; bat --color=always --style=numbers --highlight-line=$n --line-range=$((n>30?n-30:1)):$((n+30)) {1} 2>/dev/null || head -n $(( n + 30 )) {1} 2>/dev/null | tail -n 60' \ + --preview 'preview {1} {2}' \ --preview-window='right:60%')" || { zle -I; zle reset-prompt; return; } local file="${selection%%:*}" local line="${${selection#*:}%%:*}"