summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-04-23 22:39:07 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-04-23 22:39:07 +0900
commit36924d0b1c7c8f01739316ed6e68c78c042e3973 (patch)
tree4c9aae69860160605adabc29ed3d2c1e7df9d569 /shell
parent6ed9de9051660dff636a14d86ad31cc25973a04c (diff)
downloadfzf-36924d0b1c7c8f01739316ed6e68c78c042e3973.tar.gz
[zsh] Do not change LBUFFER on empty selection (CTRL-R)
Diffstat (limited to 'shell')
-rw-r--r--shell/key-bindings.zsh14
1 files changed, 8 insertions, 6 deletions
diff --git a/shell/key-bindings.zsh b/shell/key-bindings.zsh
index 451e418e..17608670 100644
--- a/shell/key-bindings.zsh
+++ b/shell/key-bindings.zsh
@@ -38,13 +38,15 @@ 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')
- LBUFFER=!$num
- if setopt | grep nobanghist > /dev/null; then
- restore_no_bang_hist=1
- unsetopt no_bang_hist
+ if [ -n "$num" ]; then
+ LBUFFER=!$num
+ if setopt | grep nobanghist > /dev/null; then
+ restore_no_bang_hist=1
+ unsetopt no_bang_hist
+ fi
+ zle expand-history
+ [ -n "$restore_no_bang_hist" ] && setopt no_bang_hist
fi
- zle expand-history
- [ -n "$restore_no_bang_hist" ] && setopt no_bang_hist
fi
zle redisplay
}