Last active
August 29, 2015 14:12
-
-
Save NigoroJr/fb68c8175c7f7394ac5b to your computer and use it in GitHub Desktop.
Shell script for configuring git aliases
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
#!/bin/sh | |
CMD='git config --global alias' | |
add_alias() { | |
ALIAS=`eval $CMD.$1` | |
if [[ -z "$ALIAS" ]]; then | |
eval "$CMD.$1 $2" | |
elif [[ $ALIAS != $2 ]]; then | |
printf "%-4s already defined as %s\n" $1 $ALIAS | |
fi | |
} | |
add_alias a add | |
add_alias c commit | |
add_alias co checkout | |
add_alias d diff | |
# Arguments with more than one word need to be quoted and spaces must be escaped | |
add_alias dc 'diff\ --cached' | |
add_alias mt mergetool | |
add_alias pl pull | |
add_alias s status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment