dircycle.plugin.zsh 1.1 KB

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. # These sequences work for xterm, Apple Terminal.app, and probably others.
  24. # Not for rxvt-unicode, but it doesn't seem differentiate Ctrl-Shift-Arrow
  25. # from plain Shift-Arrow, at least by default.
  26. # iTerm2 does not have these key combinations defined by default; you will need
  27. # to add them under "Keys" in your profile if you want to use this. You can do
  28. # this conveniently by loading the "xterm with Numeric Keypad" preset.
  29. bindkey "\e[1;6D" insert-cycledleft
  30. bindkey "\e[1;6C" insert-cycledright