dblume commited on 2021-11-03 14:03:01
Showing 1 changed files, with 16 additions and 3 deletions.
| ... | ... |
@@ -4,7 +4,15 @@ if [[ $(uname -s) != Darwin* ]] && [ -f /etc/bashrc ]; then |
| 4 | 4 |
. /etc/bashrc |
| 5 | 5 |
fi |
| 6 | 6 |
|
| 7 |
-# Some devices may not have __git_ps1, so fake it |
|
| 7 |
+if ! $(declare -F __git_ps1 >/dev/null); then |
|
| 8 |
+ # Try to source a file with __git_ps1 |
|
| 9 |
+ if [[ -e /usr/lib/git-core/git-sh-prompt ]]; then |
|
| 10 |
+ . /usr/lib/git-core/git-sh-prompt |
|
| 11 |
+ elif [[ -e /usr/share/git-core/contrib/completion/git-prompt.sh ]]; then |
|
| 12 |
+ . /usr/share/git-core/contrib/completion/git-prompt.sh |
|
| 13 |
+ fi |
|
| 14 |
+ |
|
| 15 |
+ # Still no __git_ps1? Fake it. |
|
| 8 | 16 |
if ! $(declare -F __git_ps1 >/dev/null); then |
| 9 | 17 |
__git_ps1() {
|
| 10 | 18 |
local fmt="${1:- (%s)}"
|
| ... | ... |
@@ -14,16 +22,21 @@ if ! $(declare -F __git_ps1 >/dev/null); then |
| 14 | 22 |
fi |
| 15 | 23 |
} |
| 16 | 24 |
fi |
| 25 |
+fi |
|
| 26 |
+ |
|
| 27 |
+GIT_PS1_SHOWUPSTREAM="auto" |
|
| 28 |
+GIT_PS1_SHOWDIRTYSTATE="true" |
|
| 17 | 29 |
|
| 30 |
+# Experimenting with git branch in PS1. Turn off by setting to false. |
|
| 18 | 31 |
if true ; then |
| 19 | 32 |
export PROMPT_DIRTRIM=1 |
| 20 | 33 |
# I like 023 or 030 for the git branch color. See https://i.stack.imgur.com/UQVe5.png |
| 21 | 34 |
if [[ -n $SSH_CLIENT ]]; then |
| 22 | 35 |
export PS1='$(if [ $? -eq 0 ]; then echo -e "\[\e[32m\]\xe2\x9c\x93"; |
| 23 |
- else echo -e "\[\e[31m\]\xe2\x9c\x97"; fi) \[\e[38;5;242m\]\h:\w\[\e[38;5;030m\]$(__git_ps1 " %s")\[\e[38;5;242m\]$\[\e[0m\] ' |
|
| 36 |
+ else echo -e "\[\e[31m\]\xe2\x9c\x97"; fi) \[\e[38;5;242m\]\h:\w$(__git_ps1 " \[\e[38;5;030m\]%s\[\e[38;5;242m\]")$\[\e[0m\] ' |
|
| 24 | 37 |
else |
| 25 | 38 |
export PS1='$(if [ $? -eq 0 ]; then echo -e "\[\e[32m\]\xe2\x9c\x93"; |
| 26 |
- else echo -e "\[\e[31m\]\xe2\x9c\x97"; fi) \[\e[38;5;242m\]\w\[\e[38;5;030m\]$(__git_ps1 " %s")\[\e[38;5;242m\]$\[\e[0m\] ' |
|
| 39 |
+ else echo -e "\[\e[31m\]\xe2\x9c\x97"; fi) \[\e[38;5;242m\]\w$(__git_ps1 " \[\e[38;5;030m\]%s\[\e[38;5;242m\]")$\[\e[0m\] ' |
|
| 27 | 40 |
fi |
| 28 | 41 |
else |
| 29 | 42 |
export PROMPT_DIRTRIM=4 |
| 30 | 43 |