commit 3e246a919a2dc6d143af359bd1a1366389f41b75 (patch)
parent 010d651372c477241ae8c1741ad056794320f9af
Author: Alexander Karle <akarle@umass.edu>
Date: Sun, 2 Dec 2018 23:27:03 -0500
[bash] cleaner parsing of dirty git repo for bash_prompt
I found out about --porcelain=v1 as a backward compatible way
to check if it is clean / dirty.
It returns empty if clean, so that simplifies the parse_git_dirty
function a good bit.
Diffstat:
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/bash/bash_prompt b/bash/bash_prompt
@@ -19,8 +19,7 @@ else
fi
function parse_git_dirty() {
- [[ $(git status 2> /dev/null | tail -n1) != *"working directory clean"* ]] && \
- [[ $(git status 2> /dev/null | tail -n1) != *"working tree clean"* ]] && echo "*"
+ [ "$(git status --porcelain=v1 2> /dev/null)" ] && echo "*"
}
function parse_git_branch() {