fzf: better previews

This commit is contained in:
Charles Gould 2020-12-08 22:15:19 -05:00
parent feedd66bcb
commit 4834d54818

View File

@ -5,7 +5,7 @@ set -gx FZF_DEFAULT_COMMAND "fd --type=file"
function __fzf_files
set -l output (
fd --type=file --hidden --follow --color=always --exclude=.git 2>/dev/null |
fzf --ansi --preview='bat --style=header,numbers --color=always {}' --preview-window='right:70%:hidden:wrap' --bind='?:toggle-preview' --expect='ctrl-e' --header='ctrl-e to edit'
fzf --ansi --preview='bat --style=numbers --color=always {}' --preview-window='right:70%:hidden:wrap' --bind='?:toggle-preview' --expect='ctrl-e' --header='ctrl-e to edit, ? to preview'
)
set -l key $output[1]
set -l file $output[2]
@ -25,7 +25,7 @@ function __fzf_git_log
else
set -l output (
command git logsearch |
fzf --ansi --tiebreak=index
fzf --ansi --tiebreak=index --preview='git show --color {1}' --preview-window='right:70%:hidden:wrap' --bind='?:toggle-preview' --header='? to preview'
)
if set -l commit_hash (string split --max 1 " " $output)[1]
commandline -i $commit_hash
@ -38,7 +38,7 @@ function __fzf_history
set -l separator ' | '
set -l output (
history search --null --show-time="%Y-%m-%d$separator" |
fzf --read0 --tiebreak=index --query=(commandline) --preview='echo {}' --preview-window='bottom:50%:hidden:wrap' --bind='?:toggle-preview'
fzf --read0 --tiebreak=index --query=(commandline) --preview='echo {3..}' --preview-window='bottom:50%:hidden:wrap' --bind='?:toggle-preview' --header='? to preview'
)
if set -l command (string split --max 1 $separator $output)[2..-1]
commandline -r $command