Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

.bash_prompt: Fix `parse_git_dirty` for Git v1.8.0+

Git 1.8.0+ says “nothing to commit (working directory clean)”.
Older Git versions return “nothing to commit (working directory clean)”.

Thanks to @nicolahery in #143 for the suggestion.

Conflicts:
	.bash_prompt
  • Loading branch information...
commit f6e7134bd35a832279652764ee35ac98027578da 1 parent 536b389
@mathiasbynens mathiasbynens authored committed
Showing with 4 additions and 1 deletion.
  1. +4 −1 .bash_prompt
View
5 .bash_prompt
@@ -7,9 +7,12 @@ fi
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
export GIT_PS1_SHOWSTASHSTATE=true
-
export PROMPT_DIRTRIM=3
+function parse_git_dirty() {
+ [[ $(git status 2> /dev/null | tail -n1) != *"working directory clean"* ]] && echo "*"
+}
+
if [[ ${EUID} == 0 ]] ; then
PS1='\[\033[0;37m\][\t\[\033[0;37m\]]\[\033[0;33m\][\[\033[0;36m\]\u\[\033[0;36m\]@\[\033[0;36m\]\h \[\033[1;31m\]\w\[\033[0;33m\]]\[\033[0;31m\]$(__git_ps1 "(%s)")\[\033[0;37m\]\\$ \[\033[00m\]'
else
Please sign in to comment.
Something went wrong with that request. Please try again.