Last active
August 29, 2015 14:15
-
-
Save Gregcop1/fffa4707cc958924ed79 to your computer and use it in GitHub Desktop.
Git prompt
This file contains hidden or 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
# 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