Created
September 21, 2019 14:22
-
-
Save j4rs/0c276d7b72632f7044a48f4aae774c74 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
export PS1="\[\033[36m\]\u:\[\033[32m\]\w\[\033[33m\]\$(markup_git_branch \$(parse_git_branch))\[\033[00m\]$ " | |
parse_git_branch() { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* (*\([^)]*\))*/\1/' | |
} | |
markup_git_branch() { | |
if [[ -n $@ ]]; then | |
if [[ -z $(git status --porcelain 2> /dev/null) ]]; then | |
echo -e ":\001\033[32m\002($@)\001\033[0m\002" | |
else | |
local git_status="$(git status 2> /dev/null)" | |
local git_status_porcelain="$(git status --porcelain)" | |
changes="" | |
if [[ $git_status =~ "modified:" ]]; then | |
changes+="*" | |
fi | |
if [[ $git_status_porcelain =~ "??" ]]; then | |
changes+="+" | |
fi | |
if [[ $git_status =~ "deleted:" ]]; then | |
changes+="-" | |
fi | |
echo -e ":\001\033[31m\002($@$changes)\001\033[0m\002" | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment