From 7b61d15b303db946fe127387477990185d69d15d Mon Sep 17 00:00:00 2001 From: Jens Broekens Date: Fri, 16 Feb 2024 12:07:36 +0100 Subject: [PATCH] invoke git.exe instead of git in /mnt See: https://github.com/microsoft/WSL/issues/4197 --- templates/.shrc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/templates/.shrc b/templates/.shrc index 4bb11e8..efde723 100644 --- a/templates/.shrc +++ b/templates/.shrc @@ -1,16 +1,20 @@ _PS1() { - local e=${1:-$?} cwd branch stage context + local e=${1:-$?} git=git cwd branch stage context case $e in 0) cwd='\[\033[38;5;2m\]\w\[\033[m\]' ;; *) cwd='\[\033[38;5;1m\]\w\[\033[m\]' ;; esac - branch=$(git rev-parse --abbrev-ref HEAD 2> /dev/null) + case $PWD in + /mnt/*) git=git.exe ;; + esac + + branch=$($git rev-parse --abbrev-ref HEAD 2> /dev/null) if test -n "$branch"; then - git status --porcelain 2> /dev/null | grep -q '^\w' && stage=1 - git status --porcelain 2> /dev/null | grep -qv '^\w' && stage=$((stage + 2)) + $git status --porcelain 2> /dev/null | grep -q '^\w' && stage=1 + $git status --porcelain 2> /dev/null | grep -qv '^\w' && stage=$((stage + 2)) case $stage in 1) stage='\[\033[38;5;12m\]*\[\033[m\]' ;;