Created
November 4, 2013 23:02
-
-
Save rgthree/7310781 to your computer and use it in GitHub Desktop.
.bash_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
export TERM=gnome-256color | |
tput sgr0 | |
RED=$(tput setaf 1) | |
ORANGE=$(tput setaf 172) | |
BLUE=$(tput setaf 4) | |
WHITE=$(tput setaf 7) | |
GRAY=$(tput setaf 0) | |
BOLD=$(tput bold) | |
RESET=$(tput sgr0) | |
function parse_git_branch() { | |
# Check that we are in a repo | |
inrepo="$(git rev-parse --is-inside-work-tree 2>/dev/null)" || return | |
test "$inrepo" = true || return | |
# GET BRANCH | |
branch="$(git symbolic-ref HEAD 2>/dev/null)" | |
test -z "$branch" && branch='<detached-HEAD>' | |
state="" | |
[[ $(git status 2> /dev/null | tail -n1) != *"working directory clean"* ]] && state="${state}*" | |
[[ $(git status | grep Untracked) != "" ]] && state="${state}+" | |
toReturn="" | |
color="$BLUE" | |
if [ "$state" == "*" ]; then | |
color="$ORANGE" | |
elif [ "$state" == "*+" ]; then | |
color="$RED" | |
fi | |
echo " ${color}(${branch#refs/heads/}${state})" | |
} | |
export PS1="\[$BOLD\]\[$WHITE\]\w\[$ORANGE\]\$(parse_git_branch)\[$WHITE\]\n\$ \[$RESET\]" | |
export PS2="\[$ORANGE\]→ \[$RESET\]" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment