Fixed files/directories fzf preview to use eza for directories and bat for files

This commit is contained in:
josean-dev 2024-04-25 00:17:50 -04:00
parent 8600b31188
commit d48a879e2e

8
.zshrc
View file

@ -147,7 +147,9 @@ _fzf_compgen_dir() {
source ~/fzf-git.sh/fzf-git.sh
export FZF_CTRL_T_OPTS="--preview 'bat -n --color=always --line-range :500 {}'"
show_file_or_dir_preview="if [ -d {} ]; then eza --tree --color=always {} | head -200; else bat -n --color=always --line-range :500 {}; fi"
export FZF_CTRL_T_OPTS="--preview '$show_file_or_dir_preview'"
export FZF_ALT_C_OPTS="--preview 'eza --tree --color=always {} | head -200'"
# Advanced customization of fzf options via _fzf_comprun function
@ -159,9 +161,9 @@ _fzf_comprun() {
case "$command" in
cd) fzf --preview 'eza --tree --color=always {} | head -200' "$@" ;;
export|unset) fzf --preview "eval 'echo \$'{}" "$@" ;;
export|unset) fzf --preview "eval 'echo \${}'" "$@" ;;
ssh) fzf --preview 'dig {}' "$@" ;;
*) fzf --preview "bat -n --color=always --line-range :500 {}" "$@" ;;
*) fzf --preview "$show_file_or_dir_preview" "$@" ;;
esac
}