]> gitweb @ CieloNegro.org - sugar.git/commitdiff
Auto commit by The Sugar System.
authorPHO <pho@cielonegro.org>
Wed, 11 Sep 2013 08:19:55 +0000 (17:19 +0900)
committerPHO <pho@cielonegro.org>
Wed, 11 Sep 2013 08:19:55 +0000 (17:19 +0900)
dot-files/_zshrc

index 603cdd2d925539ea4c0fe16dc3fb28914e5e419c..49c5ad2edea2b88b10344362bcd1e837eb60f1cb 100644 (file)
@@ -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