From 395f05f69033dbbd2a7726765f9499cae6fd11d8 Mon Sep 17 00:00:00 2001 From: codefalling Date: Thu, 5 Nov 2015 10:08:13 +0800 Subject: [PATCH] add plugin:percol --- plugins/percol/README.md | 22 ++++++++++++++++++++++ plugins/percol/percol.plugin.zsh | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 plugins/percol/README.md create mode 100644 plugins/percol/percol.plugin.zsh diff --git a/plugins/percol/README.md b/plugins/percol/README.md new file mode 100644 index 00000000..c2233431 --- /dev/null +++ b/plugins/percol/README.md @@ -0,0 +1,22 @@ +## percol + +Provides some useful function to make [percol](https://github.com/mooz/percol) work with zsh history and [jump plugin](https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/jump/jump.plugin.zsh) + +### Preview +![Preview](http://t1.qpic.cn/mblogpic/eb1c8f9d2b9f62d19fa8/2000.jpg) + +### Requirements + +```pip install percol +``` + +And [jump](https://github.com/robbyrussell/oh-my-zsh/blob/master/plugins/jump/jump.plugin.zsh) for `oh-my-zsh` is a optional requirement. + +### Usage + +For default + +- `^-r` bind to `percol_select_history`.You can use it to grep your history with percol. + +- `^-b` bind to `percol_select_marks`.You can use it to grep your bookmarks with percol. + diff --git a/plugins/percol/percol.plugin.zsh b/plugins/percol/percol.plugin.zsh new file mode 100644 index 00000000..2b70b261 --- /dev/null +++ b/plugins/percol/percol.plugin.zsh @@ -0,0 +1,22 @@ +if which percol &> /dev/null; then + function percol_select_history() { + local tac + tac="tail -r" + BUFFER=$(fc -l -n 1 | eval $tac | percol --query "$LBUFFER") + CURSOR=$#BUFFER + zle -R -c + } + + zle -N percol_select_history + bindkey '^R' percol_select_history +fi + +if which marks &> /dev/null; then + function percol_select_marks() { + BUFFER=$(marks | percol --query "$LBUFFER" | awk '{print $3}') + CURSOR=$#BUFFER # move cursor + zle -R -c # refresh + } + zle -N percol_select_marks + bindkey '^B' percol_select_marks +fi