Created
March 10, 2014 22:07
-
-
Save bradurani/9475484 to your computer and use it in GitHub Desktop.
add to .profile to add git branch name to cmd prompt
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
# git-related functions and aliases | |
parse_git_head () { | |
git name-rev HEAD 2> /dev/null | sed 's#HEAD\ \(.*\)# (git::\1)#' | |
} | |
function get_statuscolor { | |
if [[ "$(git status 2> /dev/null | tail -n1)" != "nothing to commit, working directory clean" ]] | |
then | |
echo $RED | |
else | |
echo $GREEN | |
fi | |
} | |
function parse_git_branch { | |
git status 2> /dev/null | grep '# On branch' | sed 's#\# On\ branch\ \(.*\)# (\1)#' | |
} | |
BLACK="\[\033[0;38m\]" | |
RED="\[\033[0;31m\]" | |
RED_BOLD="\[\033[01;31m\]" | |
BLUE="\[\033[0;34m\]" | |
BLUE_BOLD="\[\033[01;34m\]" | |
GREEN="\[\033[0;32m\]" | |
YELLOW="\[\033[0;33m\]" | |
export PS1="$YELLOW\w$(get_statuscolor)\$(parse_git_branch)$BLACK : " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Function has an error in coloring