Skip to content

Commit 2d9ec22

Browse files
committed
Merge pull request #214 from root42/untracked-files
Make counting ALL untracked files optional
2 parents 6a606da + aa0b32f commit 2d9ec22

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ git clone https://github.com/magicmonty/bash-git-prompt.git .bash-git-prompt
124124
# GIT_PROMPT_FETCH_REMOTE_STATUS=0 # uncomment to avoid fetching remote status
125125

126126
# GIT_PROMPT_SHOW_UPSTREAM=1 # uncomment to show upstream tracking branch
127-
127+
# GIT_SHOW_UNTRACKED_FILES=all # can be no, normal or all; determines counting of untracked files
128+
128129
# GIT_PROMPT_STATUS_COMMAND=gitstatus_pre-1.7.10.sh # uncomment to support Git older than 1.7.10
129130

130131
# GIT_PROMPT_START=... # uncomment for custom prompt start sequence
@@ -136,6 +137,10 @@ git clone https://github.com/magicmonty/bash-git-prompt.git .bash-git-prompt
136137
source ~/.bash-git-prompt/gitprompt.sh
137138
```
138139

140+
You can set the `GIT_SHOW_UNTRACKED_FILES` variable to `no` or `normal` to speed things up if you have lots of
141+
untracked files in your repository. This can be the case for build systems that put their build artifacts in
142+
the subdirectory structure of the git repository.
143+
139144
- `cd` to a git repository and test it!
140145

141146
#### Themes

gitstatus.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# -*- coding: UTF-8 -*-
2+
# -*- coding: utf-8 -*-
33
# gitstatus.sh -- produce the current git repo status on STDOUT
44
# Functionally equivalent to 'gitstatus.py', but written in bash (not python).
55
#
@@ -15,7 +15,11 @@ if [ -z "${__GIT_PROMPT_DIR}" ]; then
1515
__GIT_PROMPT_DIR="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
1616
fi
1717

18-
gitstatus=$( LC_ALL=C git status --untracked-files=all --porcelain --branch )
18+
if [ -z "${GIT_SHOW_UNTRACKED_FILES}" ]; then
19+
GIT_SHOW_UNTRACKED_FILES="all"
20+
fi
21+
22+
gitstatus=$( LC_ALL=C git status --untracked-files=${GIT_SHOW_UNTRACKED_FILES} --porcelain --branch )
1923

2024
# if the status is fatal, exit now
2125
[[ "$?" -ne 0 ]] && exit 0

0 commit comments

Comments
 (0)