lnk: added .fzf_custom
This commit is contained in:
29
.fzf_custom
Normal file
29
.fzf_custom
Normal 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'
|
||||
Reference in New Issue
Block a user