From dd6138a6559363871d88c594ab9d170e36959129 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 13 Mar 2015 01:27:16 +0900 Subject: Fix #142, #144 - Improve CTRL-R for zsh --- install | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'install') diff --git a/install b/install index f1fae0b2..b974afaa 100755 --- a/install +++ b/install @@ -326,7 +326,12 @@ bindkey '\ec' fzf-cd-widget # CTRL-R - Paste the selected command from history into the command line fzf-history-widget() { - LBUFFER=$(fc -l 1 | fzf +s --tac +m -n2..,.. | sed "s/ *[0-9*]* *//") + local selected + if selected=$(fc -l 1 | fzf +s --tac +m -n2..,.. -q "$LBUFFER"); then + num=$(echo "$selected" | head -1 | awk '{print $1}' | sed 's/[^0-9]//g') + LBUFFER=!$num + zle expand-history + fi zle redisplay } zle -N fzf-history-widget -- cgit v1.2.3