Skip to content

Instantly share code, notes, and snippets.

@NigoroJr
Last active August 29, 2015 14:12
Show Gist options
  • Save NigoroJr/fb68c8175c7f7394ac5b to your computer and use it in GitHub Desktop.
Save NigoroJr/fb68c8175c7f7394ac5b to your computer and use it in GitHub Desktop.
Shell script for configuring git aliases
#!/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