percol.plugin.zsh 806 B

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