diff options
author | 当轩 <me@dangxuan.pro> | 2018-07-02 05:07:35 +0800 |
---|---|---|
committer | Marc Cornellà <marc.cornella@live.com> | 2018-07-01 23:07:35 +0200 |
commit | ac0d71467be9de2e399ef99ae58d7780e1d2ff4c (patch) | |
tree | e6196b1992b797b9558541728ceb2b59205b8d88 | |
parent | 55ab532e506521069afba327432132c096885c29 (diff) | |
download | zsh-ac0d71467be9de2e399ef99ae58d7780e1d2ff4c.tar.gz zsh-ac0d71467be9de2e399ef99ae58d7780e1d2ff4c.tar.bz2 zsh-ac0d71467be9de2e399ef99ae58d7780e1d2ff4c.zip |
add plugin:percol (#4582)
* add plugin:percol
* fix format
* check percol
* fix empty history in gnome terminal
-rw-r--r-- | plugins/percol/README.md | 23 | ||||
-rw-r--r-- | plugins/percol/percol.plugin.zsh | 22 |
2 files changed, 45 insertions, 0 deletions
diff --git a/plugins/percol/README.md b/plugins/percol/README.md new file mode 100644 index 000000000..97cca6876 --- /dev/null +++ b/plugins/percol/README.md @@ -0,0 +1,23 @@ +## 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 + +```shell +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 000000000..c6adf4e1e --- /dev/null +++ b/plugins/percol/percol.plugin.zsh @@ -0,0 +1,22 @@ +if which percol &> /dev/null; then + function percol_select_history() { + local tac + which gtac &> /dev/null && tac="gtac" || { which tac &> /dev/null && tac="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 + + 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 +fi |