dblume commited on 2021-11-02 21:32:45
Showing 1 changed files, with 5 additions and 1 deletions.
... | ... |
@@ -7,7 +7,11 @@ fi |
7 | 7 |
# Some devices may not have __git_ps1, so fake it |
8 | 8 |
if ! $(declare -F __git_ps1 >/dev/null); then |
9 | 9 |
__git_ps1() { |
10 |
- printf "$1" $(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') |
|
10 |
+ local fmt="${1:-%s}" |
|
11 |
+ local branch=$(git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') |
|
12 |
+ if [ -n "$branch" ]; then |
|
13 |
+ printf "$fmt" "$branch" |
|
14 |
+ fi |
|
11 | 15 |
} |
12 | 16 |
fi |
13 | 17 |
|
14 | 18 |