[Home] Zsh logo

cpd

Zsh Wizard

Download cpd Return to Examples
  1. #
  2. # cpd Change to a Previous Directory (contained in the directory stack)
  3. #
  4. # Author W.Friebel friebel@ifh.de 13/04/95
  5. #
  6. # Usage: cpd
  7. # displays the directories in the buffer stack
  8. # chose the directory you want to cd to with the cursor keys
  9. # optionally edit the directory string
  10. # select the directory by pressing Enter (or ^X^W)
  11. # or leave the menu with ^C
  12. #
  13. # The function is of little use unless the option autopushd is set.
  14. # It is furthermore useful to set pushdsilent and pushdignoredups
  15. # the dirs or pushd function can be used in addition to preload frequently
  16. # used directories into the directory stack
  17. TRAPINT () {
  18. bindkey "^M" accept-line
  19. setopt +B
  20. trap - INT
  21. builtin let "$1 > 0" && return $[128+$1]
  22. }
  23. setopt -B
  24. bindkey -s "^M" "^X^W"
  25. bindkey "^[k" kill-region
  26. # Select_Key definition:
  27. # to column 2; to begin of line; insert cd ;
  28. # to begin of line; mark position; to begin of buffer; delete up to mark
  29. # to end of line; mark position; to end of buffer; to end of line
  30. # delete up to mark; put cd command into input buffer and execute
  31. bindkey -s "" "^[2^[|^A cd ^A^@^[<^[k^E^@^[>^E^[k^[a^X^K"
  32. cpd_var=`builtin print "### Select (and Edit) directory, Enter to accept it, ^C to quit ###"
  33. builtin print -l \`dirs \``
  34. vared cpd_var
  35. bindkey "^M" accept-line
  36. setopt +B
  37. eval $cpd_var