Last active
March 1, 2016 09:30
-
-
Save pbosetti/2ed830dab8b85e3f923f to your computer and use it in GitHub Desktop.
Bash prompt configuration for git branch names
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
# ASCII COLOR SEQUENCES: \[\033[***m\] where *** is one of the following codes: | |
# Black 0;30 Dark Gray 1;30 | |
# Blue 0;34 Light Blue 1;34 | |
# Green 0;32 Light Green 1;32 | |
# Cyan 0;36 Light Cyan 1;36 | |
# Red 0;31 Light Red 1;31 | |
# Purple 0;35 Light Purple 1;35 | |
# Brown 0;33 Yellow 1;33 | |
# Light Gray 0;37 White 1;37 | |
HL_CLR="\[\033[1;32m\]" | |
N_CLR="\[\033[0m\]" | |
function get_git_branch { | |
if [ -d ".git" ] | |
then | |
local branch=$(git branch 2>/dev/null | grep '^*' | colrm 1 2) | |
local status=$(git status | grep clean) | |
if [ ${#status} -eq 0 ] | |
then | |
local clean="*" | |
fi | |
echo ${branch}$clean | |
else | |
echo - | |
fi | |
} | |
export PS1="\\h:\W [${HL_CLR}\$(get_git_branch)${N_CLR}]\$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment