File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -32,13 +32,17 @@ alias __git_branch="git branch 2>/dev/null | grep '*' | sed 's/*\ //g'"
32
32
# From http://mediadoneright.com/content/ultimate-git-ps1-bash-prompt
33
33
# Modified.
34
34
_git_status() {
35
- local gbr=$(git branch 2>/dev/null) || return 1
35
+ local gbr
36
+ gbr=$(git branch 2>/dev/null) || return 1
36
37
gbr=$(printf %s "$gbr" | grep '*' | sed 's/*\ //g')
37
- local gst=$(LC_ALL=C git status)
38
- if printf %s "$gst" | grep -q "nothing to commit"; then
38
+ local gst
39
+ gst=$(LC_ALL=C git status 2>&1)
40
+ if printf %s "$gst" | grep -q "nothing to commit"; then
39
41
echo -e "\01\e[1m\02@\01\e[0;32m\0002$gbr\01\e[0m\02"
40
- elif printf %s "$gst" || grep -q "nothing added to commit"; then # Untracked
42
+ elif printf %s "$gst" | grep -q "nothing added to commit"; then # Untracked
41
43
echo -e "\01\e[1m\02@\01\e[0;35m\0002$gbr\01\e[0m\02"
44
+ elif printf %s "$gst" | grep -q "must be run in a work tree"; then # Not in work tree
45
+ echo -e "\01\e[1m\02@\01\e[0;37m\0002$gbr\01\e[0m\02"
42
46
else # Change not added/not merged yet
43
47
echo -e "\01\e[1m\02@\01$IRED\0002$gbr\01\e[0m\02"
44
48
fi
You can’t perform that action at this time.
0 commit comments