Created
March 30, 2015 23:03
-
-
Save iansu/e2393a2100de6dfb0b0d to your computer and use it in GitHub Desktop.
Bash cd hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd() { | |
if [[ $1 =~ ^[\.]{3,}$ ]]; then | |
# rewrite ... as ../../ etc. | |
directory="../" | |
depth=${#1} | |
for i in `seq 3 $depth`; do | |
directory+=../ | |
done | |
builtin cd "$directory" | |
else | |
builtin cd "$1" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cd ... goes up two levels, cd .... goes up three levels, etc.
Add to your .bashrc or .bash_profile and enjoy.