Last active
October 22, 2018 21:48
-
-
Save mars/3933132 to your computer and use it in GitHub Desktop.
bash prompt git status
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
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile | |
function parse_git_dirty { | |
git diff --quiet || echo " ▲ " | |
} | |
function parse_git_branch { | |
e=`echo $( { git status; } 2>&1 ) | tr '[:upper:]' '[:lower:]'` | |
if [[ ! $e =~ 'not a git repository' ]] | |
then git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)] /" | |
fi | |
} | |
export PS1="\[$(tput rev)\]\t\[$(tput sgr0)\] \[\033[1m\]---\[\033[0m\] \W \$(parse_git_branch)\[\033[1m\]---\[\033[0m\] " | |
export PS2="\[$(tput rev)\]\t\[$(tput sgr0)\] \[\033[1m\]---\[\033[0m\] " | |
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment