by sant0sk1 · 17y ago · 0 comments
cd ...
to move up two directories instead of having to cd ../..
Want to move up 4 directories? cd .....
Pretty useful, imo. Check it out setopt auto_cd
alias -g ...='../..'
alias -g ....='../../..'
alias -g .....='../../../..'
alias -g ......='../../../../..'
Then you can just type "..." and go up two directory levels, and so on. alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../../'Usage: up {x} where x is the number of directories you want to go up (e.g., 3)
function up() { local arg=${1:-1} local dir="" while [ $arg -gt 0 ]; do dir="../$dir" arg=$(($arg - 1)); done cd $dir >&/dev/null }