# 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 ** _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'