Last active
February 22, 2019 08:53
-
-
Save danieldietrich/796d0c481539c930c49fa5a8663fa2b2 to your computer and use it in GitHub Desktop.
Git 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
# ----------------------------------------------------------------------------- | |
# This is a fragment of ~/.bash_profile that adds git status and branch | |
# information to the terminal prompt. The 'colors' section is optional. | |
# ----------------------------------------------------------------------------- | |
# prompt | |
export PS1="\[\e[0;32m\]\u@\h:\[\e[1;36m\]\w\[\e[0;33m\]\$(parse_git_status)\[\e[1;32m\]\$(parse_git_branch)\[\e[1;36m\] $\[\e[0m\] " | |
# colors | |
export TERM=xterm-color | |
export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32' | |
export CLICOLOR=1 | |
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx | |
# git helpers | |
parse_git_branch() { | |
git branch --no-color 2>/dev/null | grep -E '^\*' | sed 's/\* /⎇ /' | |
} | |
parse_git_status() { | |
git status --porcelain 2>/dev/null | head -c1 | if [ $(wc -c) -gt "0" ]; then echo "?"; fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment