
Untitled
By: a guest on
Aug 21st, 2012 | syntax:
None | size: 0.62 KB | hits: 18 | expires: Never
#!/bin/bash
. /usr/lib/git-core/git-sh-setup
lookup () {
local profile=$1
local key=$2
git config -z profile.$profile.$key
}
switch_id () {
local profile=$1
local name="$(lookup $profile name)"
local email="$(lookup $profile email)"
echo "Using profile $1: $name [$email]"
git config user.profile "$profile"
git config user.name "$name"
git config user.email "$email"
}
print_id () {
local profile="$(git config user.profile)"
echo "Current profile: $(lookup $profile name) [$(lookup $profile email)]"
}
PROFILE="$1"
case $PROFILE in
"")
print_id
;;
*)
switch_id $PROFILE
;;
esac