Skip to content

Instantly share code, notes, and snippets.

@Gregcop1
Last active August 29, 2015 14:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gregcop1/fffa4707cc958924ed79 to your computer and use it in GitHub Desktop.
Save Gregcop1/fffa4707cc958924ed79 to your computer and use it in GitHub Desktop.
Git prompt
# Prompt
git_or_not() { git rev-parse --is-inside-work-tree &> /dev/null ; }
git_branch() {
local status="$(git status --porcelain 2> /dev/null)"
local color=''
if [[ "${status}" != "" ]]; then
color='\033[0;31m'
fi
echo -e "${color}$(git branch 2> /dev/null |grep -e ^* |sed 's/\* //')"
}
export -f git_or_not git_branch
PS1="\n\[\033[1;37m\]\342\224\214($(
if [[ ${EUID} == 0 ]]; then
echo '\[\033[01;31m\]';
else
echo '\[\033[01;34m\]';
fi
)\u\[\033[1;37m\])\$(
if git_or_not ; then
echo -e '\342\224\200('\$(git_branch)'\[\033[1;37m\])'
fi
) \[\033[0;34m\]\w\[\033[1;37m\]\n\342\224\224> \[\033[1;37m\]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment