dotfiles/zsh/funcs/fzf.funcs
Anthony Cicchetti 3130ff5b87 fzf
2019-09-20 14:31:53 -04:00

23 lines
554 B
Text

# from the fzf examples wiki
bind '"\C-r": "\C-x1\e^\er"'
bind -x '"\C-x1": __fzf_history';
__fzf_history ()
{
__ehc $(history | fzf --tac --tiebreak=index | perl -ne 'm/^\s*([0-9]+)/ and print "!$1"')
}
__ehc()
{
if
[[ -n $1 ]]
then
bind '"\er": redraw-current-line'
bind '"\e^": magic-space'
READLINE_LINE=${READLINE_LINE:+${READLINE_LINE:0:READLINE_POINT}}${1}${READLINE_LINE:+${READLINE_LINE:READLINE_POINT}}
READLINE_POINT=$(( READLINE_POINT + ${#1} ))
else
bind '"\er":'
bind '"\e^":'
fi
}