diff --git a/.git-switch-user b/.git-switch-user new file mode 100755 index 0000000..ad71dd0 --- /dev/null +++ b/.git-switch-user @@ -0,0 +1,7 @@ +#!/bin/bash +profile=$1 +name=$(git config -f ~/.git.d/$profile --get user.name ) +email=$(git config -f ~/.git.d/$profile --get user.email ) +echo "profile = $profile name = $name email = $email" +git config user.name = $name +git config user.email = $email diff --git a/makeprofilealias.sh b/makeprofilealias.sh new file mode 100644 index 0000000..5ed0403 --- /dev/null +++ b/makeprofilealias.sh @@ -0,0 +1,27 @@ +#!bin/bash +profile=$(git config --global --get alias.profile | wc -l) +if [ $profile = "0" ]; then +git config --global alias.profile "!bash -c \"~/.git-switch-user \$1\"" +else +echo "profile alias already defined in git" +fi +profileget=$(git config --global --get alias.profile-get | wc -l) +if [ $profileget = "0" ]; then +git config --global alias.profile-get "!bash -c \"git config -f ~/.git.d/\$1 --get \$2\"" +else +echo "profile-get alias already defined in git" +fi +profileset=$(git config --global --get alias.profile-set | wc -l) +if [ $profileset = "0" ]; then +git config --global alias.profile-set "!bash -c \"git config -f ~/.git.d/\$1 \$2 \$3\"" +else +echo "profile-set alias already defined in git" +fi +echo $(cat .git-switch-user) > ~/.git-switch-user +chmod +x ~/.git-switch-user +direx=$(ls ~/ -al| grep .git.d | wc -l) +if [ $direx = "0" ]; then +mkdir ~/.git.d +else +echo ".git.d already exists" +fi \ No newline at end of file