Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. if [[ -n $(which selecta) ]]; then
  2. # CTRL-R - Paste the selected command from history into the command line
  3. selecta-history-widget() {
  4. local selected restore_no_bang_hist
  5. if [[ -z "$LBUFFER" ]]; then
  6. selected=( $(fc -l 1 | selecta) )
  7. else
  8. selected=( $(fc -l 1 | selecta -s "$LBUFFER") )
  9. fi
  10. if $selected; then
  11. num=$selected[1]
  12. if [ -n "$num" ]; then
  13. zle vi-fetch-history -n $num
  14. fi
  15. fi
  16. zle redisplay
  17. }
  18. zle -N selecta-history-widget
  19. bindkey '^R' selecta-history-widget
  20. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement