Skip to content

Instantly share code, notes, and snippets.

@moriarty
Created November 29, 2013 13:18
Show Gist options
  • Save moriarty/7705583 to your computer and use it in GitHub Desktop.
Save moriarty/7705583 to your computer and use it in GitHub Desktop.
script to set ~/.gitconfig to students gitconfig written for youbot
#!/usr/bin/env bash
#
# This is a shared machine. I have added this
# quick script to set the git config variables
#
# If you want this to work add
#
if [ -d ~/gitconfig ]; then
user="$1"
if [ -z $user ]; then
echo "Usage: \$ git-set-user [username]"
echo "available usernames are:"
ls ~/gitconfig --format=single-column |\
grep gitconfig |\
sed -e 's/\.gitconfig//'
exit
fi
if [ -f ~/gitconfig/${user}.gitconfig ]; then
while true; do
read -p "Replace ~/.gitconfig with ${user}.gitconfig? [y/n] " yn
case $yn in
[Yy]* ) mv ~/gitconfig/NOTICE.txt ~/.gitconfig;
cat ~/gitconfig/${user}.gitconfig >> ~/.gitconfig; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no";;
esac
done
else
echo "the user: ${user}, does not have a gitconfig"
echo "please add a gitconfig file:"
echo "~/gitconfig/${user}.gitconfig"
exit
fi
else
echo "the directory ~/gitconfig does not exist"
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment