From 4caecc2510361ac96d3f83e6553a87af452b4d90 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 e3149af..e5756bf 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\]' ;;