scripts

My personal collection of scripts
git clone git://src.gearsix.net/scriptsscripts.zip
Log | Files | Refs | Atom | README | LICENSE

git-cfg.sh (raw) (937B)


   1 #!/usr/bin/env sh
   2 # git-cfg
   3 # description: set git config user.name ($1) & user.email ($2) in current dir, defaults to using --local
   4 # ARGUMENTS: -g, --global = "git config --global ..." | -h, --help = prints help
   5 
   6 if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
   7 	echo "Usage: git-cfg [ARGUMENTS] [NAME] [EMAIL]"
   8 	echo ""
   9 	echo "shorthand script to set the user.name and user.email values in a git"
  10 	echo "config."
  11 	echo ""
  12 	echo "ARGUMENTS"
  13 	echo "  -l, --local   use 'git config --local (default)"
  14 	echo "  -g, --global  use 'git config --global'"
  15 	exit
  16 fi
  17 
  18 global=0
  19 if [ "$1" = "--global" ] || [ "$1" = "-g" ]; then
  20 	global=1
  21 	shift
  22 elif [ "$1" = "--local" ] || [ "$1" = "-l" ]; then
  23 	shift
  24 fi
  25 
  26 username="$1"
  27 useremail="$2"
  28 
  29 if [ $global -eq 1 ]; then
  30 	git config --global user.name "$username"
  31 	git config --global user.email "$useremail"
  32 else
  33 	git config --local user.name "$username"
  34 	git config --local user.email "$useremail"
  35 fi