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

index 2472a04075438350b4df344cda3528ea948998a5..603cdd2d925539ea4c0fe16dc3fb28914e5e419c 100644 (file)
@@ -127,6 +127,53 @@ function print_directory_info() {
     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