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>
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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#*:}%%:*}"
|
||||
|
||||
Reference in New Issue
Block a user