Skip to content

Commit b874b75

Browse files
committed
Update and simplify dirty feature so it detects untracked files again
1 parent c729611 commit b874b75

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

prompt.sh

+4-22
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,11 @@ find_git_branch() {
1313
}
1414

1515
find_git_dirty() {
16-
if [[ -z "$git_branch" ]]
17-
then
18-
git_dirty=''
16+
local status=$(git status --porcelain 2> /dev/null)
17+
if [[ "$status" != "" ]]; then
18+
git_dirty='*'
1919
else
20-
# Based on: http://stackoverflow.com/a/2659808/170413
21-
local err
22-
if err=$(git diff-files --quiet 2>&1)
23-
then
24-
if git diff-index --quiet --cached HEAD
25-
then
26-
git_dirty=''
27-
else
28-
# Can't figure out different colors
29-
git_dirty="^"
30-
fi
31-
elif [ -n "$err" ]
32-
then
33-
# Some error - most likely that it was run within $GIT_DIR
34-
# Resolve repo root instead? `git rev-parse --git-dir` does not work, nor does the 'git root' alias trick
35-
git_dirty=""
36-
else
37-
git_dirty="*"
38-
fi
20+
git_dirty=''
3921
fi
4022
}
4123

0 commit comments

Comments
 (0)