fi
}
+function ppgrep() {
+ local -a percol_opts
+
+ if [[ $# -gt 0 ]]; then
+ percol_opts=("--query" "$1")
+ fi
+
+ ps aux | percol "${percol_opts[@]}" | awk '{ print $2 }'
+}
+
+function ppkill() {
+ local -a ppgrep_opts
+
+ if [[ $1 =~ "^[^-]" ]]; then
+ ppgrep_opts=("$1")
+ shift
+ fi
+
+ ppgrep "${ppgrep_opts[@]}" | xargs kill "$@"
+}
+
+function percol_select_history() {
+ local -a tac_cmd
+
+ if which gtac >&/dev/null; then
+ tac_cmd=("gtac")
+ elif which tac >&/dev/null; then
+ tac_cmd=("tac")
+ else
+ tac_cmd=("cat")
+ fi
+
+ BUFFER=$("${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
+ zle accept-line
+ fi
+}
+if which percol >&/dev/null; then
+ zle -N percol_select_history
+ bindkey '^R' percol_select_history
+fi
+
HISTFILE="$HOME/.zhistory"
HISTSIZE=6000000
SAVEHIST=6000000