From ac0d71467be9de2e399ef99ae58d7780e1d2ff4c Mon Sep 17 00:00:00 2001 From: 当轩 Date: Mon, 2 Jul 2018 05:07:35 +0800 Subject: add plugin:percol (#4582) * add plugin:percol * fix format * check percol * fix empty history in gnome terminal --- plugins/percol/percol.plugin.zsh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 plugins/percol/percol.plugin.zsh (limited to 'plugins/percol/percol.plugin.zsh') 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 -- cgit v1.2.3-70-g09d2