percol.plugin.zsh
806 bytes
1(( ${+commands[percol]} )) || return
2
3function percol_select_history() {
4 # print history in reverse order (from -1 (latest) to 1 (oldest))
5 BUFFER=$(fc -l -n -1 1 | percol --query "$LBUFFER")
6 CURSOR=$#BUFFER
7 zle -R -c
8}
9zle -N percol_select_history
10bindkey -M emacs '^R' percol_select_history
11bindkey -M viins '^R' percol_select_history
12bindkey -M vicmd '^R' percol_select_history
13
14if (( ${+functions[marks]} )); then
15 function percol_select_marks() {
16 # parse directory from marks output (markname -> path) and quote if necessary
17 BUFFER=${(q)"$(marks | percol --query "$LBUFFER")"##*-> }
18 CURSOR=$#BUFFER
19 zle -R -c
20 }
21 zle -N percol_select_marks
22 bindkey -M emacs '^B' percol_select_marks
23 bindkey -M viins '^B' percol_select_marks
24 bindkey -M vicmd '^B' percol_select_marks
25fi