1058N/A# DIRECTORY MANIPULATION FUNCTIONS, REPLACES CD
1058N/A# Uses global parameters _push_max _push_top _push_stack
1058N/Ainteger _push_max=${CDSTACK-32} _push_top=${CDSTACK-32}
1058N/A# Display directory stack -- $HOME displayed as ~
1058N/A typeset dir="${PWD#$HOME/}"
1058N/A select i in "$dir" "${_push_stack[@]}"
1058N/A# Change directory and put directory on front of stack
n=_push_top+${1#-}-1 type=2
1) # keep present directory
n=_push_top+${1}-2 type=2
then if ((n >= _push_max+1))
then print -u2 cd: Directory stack not that deep.
else dir=${_push_stack[n]}
print "\033[?${#PWD};2v$PWD\c"
1) # swap first two elements
_push_stack[_push_top]=$dir
2|3) # put $dir on top and shift down by one until top
for dir in "$dir" "${_push_stack[@]}"
_push_stack[_push_top=_push_top-1]=$dir
# Menu driven change directory command
typeset dir="${PWD#$HOME/}"
PS3='Select by number or enter a name: '
select dir in "$dir" "${_push_stack[@]}"