diff --git a/assets/default/fish/functions/__fzf_preview.fish b/assets/default/fish/functions/__fzf_preview.fish new file mode 100644 index 0000000..b3be698 --- /dev/null +++ b/assets/default/fish/functions/__fzf_preview.fish @@ -0,0 +1,16 @@ +# A function that can be used as the preview function for FZF to make fancy previews with syntax highlighting +function __fzf_preview + if file --mime "$argv" | grep -q binary + echo "$argv is a binary file" + else + if command --quiet --search bat + bat --color=always --line-range :500 "$argv" + else if command --quiet --search chroma + chroma "$argv" | head -250 + else if command --quiet --search coderay + coderay "$argv" | head -250 + else + head -250 "$argv" + end + end +end diff --git a/assets/default/fish/functions/fzf_extensions.fish b/assets/default/fish/functions/fzf_extensions.fish deleted file mode 100644 index f73c522..0000000 --- a/assets/default/fish/functions/fzf_extensions.fish +++ /dev/null @@ -1,8 +0,0 @@ -# A function that can be used as the preview function for FZF to make fancy previews with syntax highlighting -function __fzf_preview - if file --mime "$argv" | grep -q binary - echo "$argv is a binary file" - else - coderay "$argv" ;or cat "$argv" 2> /dev/null | head -250 - end -end diff --git a/assets/default/fish/init/env.fish b/assets/default/fish/init/env.fish index 3c97abf..a3ffde0 100644 --- a/assets/default/fish/init/env.fish +++ b/assets/default/fish/init/env.fish @@ -16,6 +16,11 @@ end if [ -n "$FZF_DEFAULT_COMMAND" ] set -gx FZF_CTRL_T_COMMAND "$FZF_DEFAULT_COMMAND \$dir" end +set -gx FZF_DEFAULT_OPTS " +--preview-window=:hidden +--preview='__fzf_preview {}' +--bind '?:toggle-preview' +" # Vim Colors so that they can be set by env set -q VIM_COLOR; set -gx VIM_COLOR (eval $HOME/bin/get_vim_colorscheme.sh); or set -gx VIM_COLOR wombat256mod