From d48a879e2e3246bb5c8ba2e66e7277fdd8cff067 Mon Sep 17 00:00:00 2001 From: josean-dev Date: Thu, 25 Apr 2024 00:17:50 -0400 Subject: [PATCH] Fixed files/directories fzf preview to use eza for directories and bat for files --- .zshrc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.zshrc b/.zshrc index 25c3faf..35b39df 100644 --- a/.zshrc +++ b/.zshrc @@ -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 }