Skip to content

Instantly share code, notes, and snippets.

@manafire
Last active December 31, 2015 06:39
Show Gist options
  • Save manafire/7949060 to your computer and use it in GitHub Desktop.
Save manafire/7949060 to your computer and use it in GitHub Desktop.
Change directory by substituting a string in current working directory with another. Throw this in your aliases file or your rc, or profile file and enjoy.
#
# CD substitution
# usage: cds [target] [substitution]
#
# if you have a current working directory like this:
# ~/code/myproject/en/images/
# and you type: cds en fr
# you will change to this directory:
# ~/code/myproject/fr/images/
function cds {
cd `echo $(pwd) | sed s:/$1/:/$2/:`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment