dblume commited on 2021-11-02 16:22:41
Showing 1 changed files, with 6 additions and 4 deletions.
| ... | ... |
@@ -4,20 +4,22 @@ if [[ $(uname -s) != Darwin* ]] && [ -f /etc/bashrc ]; then |
| 4 | 4 |
. /etc/bashrc |
| 5 | 5 |
fi |
| 6 | 6 |
|
| 7 |
-parse_git_branch() {
|
|
| 7 |
+# Some devices may not have __git_ps1, so fake it |
|
| 8 |
+if ! $(declare -F __git_ps1 > /dev/null); then |
|
| 9 |
+ __git_ps1() {
|
|
| 8 | 10 |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ ⌥\1/' |
| 9 |
- #git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1/' |
|
| 10 | 11 |
} |
| 12 |
+fi |
|
| 11 | 13 |
|
| 12 | 14 |
if true ; then |
| 13 | 15 |
export PROMPT_DIRTRIM=1 |
| 14 | 16 |
# I like 023 or 030 for the git branch color. See https://i.stack.imgur.com/UQVe5.png |
| 15 | 17 |
if [[ -n $SSH_CLIENT ]]; then |
| 16 | 18 |
export PS1='$(if [ $? -eq 0 ]; then echo -e "\[\e[32m\]\xe2\x9c\x93"; |
| 17 |
- else echo -e "\[\e[31m\]\xe2\x9c\x97"; fi) \[\e[38;5;242m\]\h:\w\[\e[38;5;030m\]$(parse_git_branch)\[\e[38;5;242m\]$\[\e[0m\] ' |
|
| 19 |
+ 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\] ' |
|
| 18 | 20 |
else |
| 19 | 21 |
export PS1='$(if [ $? -eq 0 ]; then echo -e "\[\e[32m\]\xe2\x9c\x93"; |
| 20 |
- else echo -e "\[\e[31m\]\xe2\x9c\x97"; fi) \[\e[38;5;242m\]\w\[\e[38;5;030m\]$(parse_git_branch)\[\e[38;5;242m\]$\[\e[0m\] ' |
|
| 22 |
+ 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\] ' |
|
| 21 | 23 |
fi |
| 22 | 24 |
else |
| 23 | 25 |
export PROMPT_DIRTRIM=4 |
| 24 | 26 |