mirror of
https://github.com/ViViDboarder/shoestrap.git
synced 2024-11-22 02:56:30 +00:00
Add preview toggle to fzf/fish
This commit is contained in:
parent
cb2c0ea26d
commit
a666ccf041
16
assets/default/fish/functions/__fzf_preview.fish
Normal file
16
assets/default/fish/functions/__fzf_preview.fish
Normal file
@ -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
|
@ -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
|
|
@ -16,6 +16,11 @@ end
|
|||||||
if [ -n "$FZF_DEFAULT_COMMAND" ]
|
if [ -n "$FZF_DEFAULT_COMMAND" ]
|
||||||
set -gx FZF_CTRL_T_COMMAND "$FZF_DEFAULT_COMMAND \$dir"
|
set -gx FZF_CTRL_T_COMMAND "$FZF_DEFAULT_COMMAND \$dir"
|
||||||
end
|
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
|
# 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
|
set -q VIM_COLOR; set -gx VIM_COLOR (eval $HOME/bin/get_vim_colorscheme.sh); or set -gx VIM_COLOR wombat256mod
|
||||||
|
Loading…
Reference in New Issue
Block a user