Created
April 24, 2013 16:31
-
-
Save ruslanosipov/5453510 to your computer and use it in GitHub Desktop.
Little script that swaps local gitconfig files used in git version 1.7.10 and up (include.path ~/.gitconfig.local)
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
#!/usr/bin/env sh | |
# Ruslan Osipov, April 2013 | |
# Little script that swaps local gitconfig files used in git version | |
# 1.7.10 and up (include.path ~/.gitconfig.local). | |
# | |
# Requirements: | |
# Little set_prompt function from | |
# https://github.com/ruslanosipov/dotfiles/blob/master/.bashrc | |
# ~/.gitconfig.local | |
# ~/.gitconfig.local.switch | |
# Both .gitconfig files should have user.name section in them | |
usrswitch() { | |
if [ ! -f ~/.gitconfig.local ]; then | |
echo Can\'t find ~/.gitconfig.local! && return 10 | |
fi | |
if [ ! -f ~/.gitconfig.local.switch ]; then | |
echo Can\'t find ~/.gitconfig.local.switch! && return 10 | |
fi | |
# swap .gitconfig.local with .gitconfig.local.switch | |
cp ~/.gitconfig.local.switch ~/.gitconfig-local-tmp | |
cp ~/.gitconfig.local ~/.gitconfig.local.switch | |
cp ~/.gitconfig-local-tmp ~/.gitconfig.local | |
rm ~/.gitconfig-local-tmp | |
# display swap result in PS1 | |
user=`cat ~/.gitconfig.local | grep name | awk -F"=" '{print $2}'` | |
echo $user > ~/.username | |
set_prompt 4 | |
} | |
usrswitch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment