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