dblume commited on 2021-11-07 16:41:13
Showing 1 changed files, with 8 additions and 1 deletions.
| ... | ... |
@@ -16,18 +16,25 @@ if ! $(declare -F __git_ps1 >/dev/null); then |
| 16 | 16 |
|
| 17 | 17 |
# Still no __git_ps1? Fake it. |
| 18 | 18 |
if ! $(declare -F __git_ps1 >/dev/null); then |
| 19 |
+ # By icetan at https://stackoverflow.com/a/35513635/9181 |
|
| 20 |
+ # Ex. to test if in a git repo: "rtrav .git $PWD" |
|
| 21 |
+ rtrav() { [ -e "$2"/"$1" ] || { [ "$2" != / ] && rtrav "$1" $(dirname "$2"); } }
|
|
| 22 |
+ |
|
| 19 | 23 |
__git_ps1() {
|
| 24 |
+ if rtrav .git "$PWD"; then |
|
| 20 | 25 |
local fmt="${1:- (%s)}"
|
| 21 | 26 |
local branch=$(git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/') |
| 22 | 27 |
if [ -n "$branch" ]; then |
| 23 | 28 |
printf -- "$fmt" "$branch" |
| 24 | 29 |
fi |
| 30 |
+ fi |
|
| 25 | 31 |
} |
| 26 | 32 |
fi |
| 27 | 33 |
fi |
| 28 | 34 |
|
| 29 | 35 |
GIT_PS1_SHOWUPSTREAM="auto" |
| 30 | 36 |
GIT_PS1_SHOWDIRTYSTATE="true" |
| 37 |
+GIT_PS1_STATESEPARATOR="" |
|
| 31 | 38 |
|
| 32 | 39 |
# Experimenting with git branch in PS1. Turn off by setting to false. |
| 33 | 40 |
if true ; then |
| ... | ... |
@@ -142,7 +149,7 @@ md() {
|
| 142 | 149 |
echo "rm \"$T\" >/dev/null 2>&1" | at now + 2 minutes |
| 143 | 150 |
else |
| 144 | 151 |
# Set BROWSER to your web browser's path |
| 145 |
- "$BROWSER" $(realpath --relative-to=$PWD $T) |
|
| 152 |
+ "$BROWSER" '\\wsl$/Ubuntu'$T |
|
| 146 | 153 |
fi |
| 147 | 154 |
fi |
| 148 | 155 |
} |
| 149 | 156 |