]> gitweb @ CieloNegro.org - sugar.git/blobdiff - dot-files/_zshrc
Auto commit by The Sugar System.
[sugar.git] / dot-files / _zshrc
index 603cdd2d925539ea4c0fe16dc3fb28914e5e419c..50e0f91bb389949a564cdd4125c015e8aee5f337 100644 (file)
@@ -159,14 +159,18 @@ function percol_select_history() {
         tac_cmd=("cat")
     fi
 
-    BUFFER=$("${tac_cmd[@]}" "$HISTFILE" | \
+    local selected
+    selected=$("${tac_cmd[@]}" "$HISTFILE" | \
         sed 's/^: [0-9]*:[0-9]*;//' | \
+        awk 'seen[$0] {next} {seen[$0]++; print}' | \
         percol --match-method regex --query "$LBUFFER")
-    CURSOR=$#BUFFER # move cursor to the end of line
-    zle redisplay
-
-    if [[ -n $BUFFER ]]; then
-        zle accept-line
+    if [[ $? -eq 0 ]]; then
+        BUFFER="$selected"
+        CURSOR="$#BUFFER" # move cursor to the end of line
+        zle redisplay
+        #zle accept-line  # uncomment this to execute the selected one immediately.
+    else
+        zle redisplay
     fi
 }
 if which percol >&/dev/null; then