Last active
October 4, 2016 19:56
-
-
Save leonardovillela/b35d6775009dc57e5809612fe8f3e730 to your computer and use it in GitHub Desktop.
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
function git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/' | |
} | |
# http://unix.stackexchange.com/questions/88307/escape-sequences-with-echo-e-in-different-shells | |
function markup_git_branch { | |
if [[ "x$1" = "x" ]]; then | |
echo -e "[$1]" | |
else | |
if [[ $(git status 2> /dev/null | tail -n1) = "nothing to commit, working directory clean" ]]; then | |
echo -e '\033[1;32m['"$1"']\033[0;30m' | |
else | |
echo -e '\033[1;31m['"$1"'*]\033[0;30m' | |
fi | |
fi | |
} | |
export PS1='\[\033[0;32m\]\[\033[0m\033[0;32m\]\u\[\033[0;36m\]@\[\033[0;36m\]\h \w\[\033[0;32m\] $(markup_git_branch $(git_branch))\n\[\033[0;32m\]└─\[\033[0m\033[0;32m\] \$\[\033[0m\033[0;32m\] ▶\[\033[0m\] ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment