Skip to content

Instantly share code, notes, and snippets.

@cchacin
Created February 4, 2015 21:43
Show Gist options
  • Save cchacin/9039dd5df5b2c320927a to your computer and use it in GitHub Desktop.
Save cchacin/9039dd5df5b2c320927a to your computer and use it in GitHub Desktop.
Ondir configuration to change git config user.* preferences
enter ~/Git/work/([^/]+)
if [ -r .git ]; then
git config user.name "Username";
git config user.email "user@work.com";
echo 'Switched to git user/email settings for cchacin@work.com - WORK.';
fi
enter ~/Git/personal/([^/]+)
if [ -r .git ]; then
git config user.name "Username";
git config user.email "user@personal.com";
echo 'Switched to git user/email settings for user@personal.com - PERSONAL.';
fi
# ondir configuration
cd() {
builtin cd "$@" && eval "`ondir \"$OLDPWD\" \"$PWD\"`"
}
pushd() {
builtin pushd "$@" && eval "`ondir \"$OLDPWD\" \"$PWD\"`"
}
popd() {
builtin popd "$@" && eval "`ondir \"$OLDPWD\" \"$PWD\"`"
}
eval "`ondir /`"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment