From 4003f6c2eee6215e6f77d8d11d17d2ef60461056 Mon Sep 17 00:00:00 2001 From: PHO Date: Wed, 11 Sep 2013 17:19:55 +0900 Subject: [PATCH] Auto commit by The Sugar System. --- dot-files/_zshrc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dot-files/_zshrc b/dot-files/_zshrc index 603cdd2..49c5ad2 100644 --- a/dot-files/_zshrc +++ b/dot-files/_zshrc @@ -159,14 +159,17 @@ function percol_select_history() { tac_cmd=("cat") fi - BUFFER=$("${tac_cmd[@]}" "$HISTFILE" | \ + local selected + selected=$("${tac_cmd[@]}" "$HISTFILE" | \ sed 's/^: [0-9]*:[0-9]*;//' | \ percol --match-method regex --query "$LBUFFER") - CURSOR=$#BUFFER # move cursor to the end of line - zle redisplay - - if [[ -n $BUFFER ]]; then + if [[ $? -eq 0 ]]; then + BUFFER="$selected" + CURSOR="$#BUFFER" # move cursor to the end of line + zle redisplay zle accept-line + else + zle redisplay fi } if which percol >&/dev/null; then -- 2.40.0