# # cpd Change to a Previous Directory (contained in the directory stack) # # Author W.Friebel friebel@ifh.de 13/04/95 # # Usage: cpd # displays the directories in the buffer stack # chose the directory you want to cd to with the cursor keys # optionally edit the directory string # select the directory by pressing Enter (or ^X^W) # or leave the menu with ^C # # The function is of little use unless the option autopushd is set. # It is furthermore useful to set pushdsilent and pushdignoredups # the dirs or pushd function can be used in addition to preload frequently # used directories into the directory stack TRAPINT () { bindkey "^M" accept-line setopt +B trap - INT builtin let "$1 > 0" && return $[128+$1] } setopt -B bindkey -s "^M" "^X^W" bindkey "^[k" kill-region # Select_Key definition: # to column 2; to begin of line; insert cd ; # to begin of line; mark position; to begin of buffer; delete up to mark # to end of line; mark position; to end of buffer; to end of line # delete up to mark; put cd command into input buffer and execute bindkey -s "" "^[2^[|^A cd ^A^@^[<^[k^E^@^[>^E^[k^[a^X^K" cpd_var=`builtin print "### Select (and Edit) directory, Enter to accept it, ^C to quit ###" builtin print -l \`dirs \`` vared cpd_var bindkey "^M" accept-line setopt +B eval $cpd_var