dircycle.plugin.zsh 865 B

12345678910111213141516171819202122232425262728293031323334353637
  1. # enables cycling through the directory stack using
  2. # Ctrl+Shift+Left/Right
  3. #
  4. # left/right direction follows the order in which directories
  5. # were visited, like left/right arrows do in a browser
  6. # NO_PUSHD_MINUS syntax:
  7. # pushd +N: start counting from left of `dirs' output
  8. # pushd -N: start counting from right of `dirs' output
  9. insert-cycledleft () {
  10. emulate -L zsh
  11. setopt nopushdminus
  12. builtin pushd -q +1 &>/dev/null || true
  13. zle reset-prompt
  14. }
  15. zle -N insert-cycledleft
  16. insert-cycledright () {
  17. emulate -L zsh
  18. setopt nopushdminus
  19. builtin pushd -q -0 &>/dev/null || true
  20. zle reset-prompt
  21. }
  22. zle -N insert-cycledright
  23. # add key bindings for iTerm2
  24. if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
  25. bindkey "^[[1;6D" insert-cycledleft
  26. bindkey "^[[1;6C" insert-cycledright
  27. else
  28. bindkey "\e[1;6D" insert-cycledleft
  29. bindkey "\e[1;6C" insert-cycledright
  30. fi