lnk: added .fzf_custom

This commit is contained in:
Lnk User
2025-06-26 18:26:55 +02:00
parent 407d4d7611
commit 9d4f3f2412
2 changed files with 30 additions and 0 deletions

29
.fzf_custom Normal file
View File

@@ -0,0 +1,29 @@
# FZF options
export FZF_COMPLETION_OPTS='--border --info=inline'
[ -x ~/Software/bin/eza ] && export FZF_ALT_C_OPTS="--preview 'eza --tree --level=2 {} | head -200'"
[ -x "$(command -v tree)" ] && export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -200'"
# Custom fuzzy completion for "z" command
# e.g. z **<TAB>
_fzf_complete_z() {
_fzf_complete --multi --reverse --preview 'eza --tree --level=2 {} | head -200' --prompt="z> " -- "$@" < <(
z -l | sort -nr | sed 's/^[0-9,.]* *//'
)
}
[ -n "$BASH" ] && complete -F _fzf_complete_z -o default -o bashdefault z
export FZF_GHQ_OPTS="--preview 'cat \$(find {} -iname readme*) | head -200'"
[ -x "$(command -v bat)" ] && export FZF_GHQ_OPTS="--preview 'bat -l md --color=always \$(find {} -iname readme*) | head -200'"
[ -x "$(command -v glow)" ] && export FZF_GHQ_OPTS="--preview 'glow -s dark \$(find {} -iname readme*) | head -200'"
function fzf-repo() {
cmd="ghq list --full-path | fzf --query \"$LBUFFER\" $FZF_GHQ_OPTS"
# local selected_repo=$(ghq list --full-path | fzf --query "$LBUFFER" --preview 'glow -s dark $(find {} -iname readme*) | head -200')
local selected_repo=$(eval $cmd)
if [ -n "$selected_repo" ]; then
if [ -t 1 ]; then
pushd ${selected_repo}
fi
fi
}
bind -x '"\C-g": fzf-repo'