[zsh] Do not change LBUFFER on empty selection (CTRL-R)

This commit is contained in:
Junegunn Choi 2015-04-23 22:39:07 +09:00
parent 6ed9de9051
commit 36924d0b1c

View File

@ -38,6 +38,7 @@ fzf-history-widget() {
local selected restore_no_bang_hist
if selected=$(fc -l 1 | $(__fzfcmd) +s --tac +m -n2..,.. --tiebreak=index --toggle-sort=ctrl-r -q "$LBUFFER"); then
num=$(echo "$selected" | head -1 | awk '{print $1}' | sed 's/[^0-9]//g')
if [ -n "$num" ]; then
LBUFFER=!$num
if setopt | grep nobanghist > /dev/null; then
restore_no_bang_hist=1
@ -46,6 +47,7 @@ fzf-history-widget() {
zle expand-history
[ -n "$restore_no_bang_hist" ] && setopt no_bang_hist
fi
fi
zle redisplay
}
zle -N fzf-history-widget