Skip to content

Instantly share code, notes, and snippets.

@bakineggs
Created October 25, 2011 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bakineggs/1314452 to your computer and use it in GitHub Desktop.
Save bakineggs/1314452 to your computer and use it in GitHub Desktop.
prompt tells me about possibly problematic git author setting
# Git completion
if [[ -f "$HOME/.git-completion.bash" ]]; then
source "$HOME/.git-completion.bash"
__has_gitdir=true
elif [[ -n $(which brew) && -f "`brew --prefix`/etc/bash_completion.d/git-completion.bash" ]]; then
. `brew --prefix`/etc/bash_completion.d/git-completion.bash
__has_gitdir=true
else
function __git_ps1() {
printf ""
}
__has_gitdir=false
fi
function __git_author() {
if [ __has_gitdir -a -n "$(__gitdir)" ]; then
email=`git config user.email`
domain=${email#*@}
user=${email%@*}
if [ "$user" != "${user%+*}" ]; then
users_to_color=${user#*+}
colored_users=${user%%+*}
while [ "$users_to_color" != "" ]; do
colored_users="$colored_users${COLOR_LIGHT_RED}+${COLOR_LIGHT_CYAN}${users_to_color%%+*}"
if [ "$users_to_color" = "${users_to_color#*+}" ]; then
users_to_color=""
else
users_to_color=${users_to_color#*+}
fi
done
user=$colored_users
fi
working_dir=`pwd`
if [ ${working_dir:0:${#SQUARE_HOME}} = $SQUARE_HOME ]; then
if [ $domain != "squareup.com" ]; then
domain="${COLOR_LIGHT_RED}$domain${COLOR_LIGHT_CYAN}"
fi
else
if [ $domain = "squareup.com" ]; then
domain="${COLOR_LIGHT_RED}$domain${COLOR_LIGHT_CYAN}"
fi
fi
printf " $user@$domain"
fi
}
export PS1="\[${COLOR_LIGHT_GRAY}\]\w\[${COLOR_LIGHT_CYAN}\]\$(__git_author)\$(__git_ps1 \" %s\")\[${COLOR_NC}\] "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment