Created
June 11, 2009 00:31
-
-
Save rupa/127617 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# change part of pwd path, and cd to it | |
# example: | |
# /usr/lib/foo$ cx lib src | |
# /usr/src/foo$ | |
# slashes need double escaping: \\/ | |
# surprisingly, most everything else doesn't | |
cx() { | |
local cd="$PWD" | |
while [ $1 ]; do | |
cd="$(echo $cd | sed "s/$1/$2/")" | |
shift; shift | |
done | |
shopt -s cdspell | |
cd $cd | |
shopt -u cdspell | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment