PS1 bash 命令替换不适用于 windows 10

PS1 bash command substitution not working on windows 10

这是我的脚本,用于设置我的 bash PS1

# Reset
Color_Off="\[3[0m\]"       # Text Reset

# Regular Colors
Black="\[3[0;30m\]"        # Black
Red="\[3[0;31m\]"          # Red
Green="\[3[0;32m\]"        # Green
Yellow="\[3[0;33m\]"       # Yellow
Blue="\[3[0;34m\]"         # Blue
Purple="\[3[0;35m\]"       # Purple
Cyan="\[3[0;36m\]"         # Cyan
White="\[3[0;37m\]"        # White

# Bold
BBlack="\[3[1;30m\]"       # Black
BRed="\[3[1;31m\]"         # Red
BGreen="\[3[1;32m\]"       # Green
BYellow="\[3[1;33m\]"      # Yellow
BBlue="\[3[1;34m\]"        # Blue
BPurple="\[3[1;35m\]"      # Purple
BCyan="\[3[1;36m\]"        # Cyan
BWhite="\[3[1;37m\]"       # White

# Various variables you might want for your PS1 prompt instead
Time12h="\T"
Time12a="\@"
PathShort="\w"
PathFull="\W"
NewLine="\n"
Jobs="\j"

GIT_PS1_SHOWDIRTYSTATE="true"

PS1="\n${BBlack}\u@\h ${BRed}\w${BYellow}$(__git_ps1 ' { %s }')${BGreen}\n$ "

直到昨天我决定将我的笔记本电脑更新到 windows 10 时,它一直运行良好。

现在它抛出这个错误:

bash: command substitution: line 1: syntax error near unexpected token `)'
bash: command substitution: line 1: `__git_ps1 ' { %s }')'

知道导致此错误的原因吗?

问题是 ps1 中的结束新行。我找到了解决方案 here。将我的 PS1 更改为:

PS1="\n${BBlack}\u@\h ${BRed}\w${BYellow}$(__git_ps1 ' { %s }')${BGreen}"$'\n$ '

我认为错误来自这里$(__git_ps1.....

应该是$(__git_ps1.....(没有'\')

我已经在 (windows 10 / git 2.10.2):

上测试过了
PS1="\n${White}\u@\h ${BRed}\w${BYellow} $(__git_ps1 ' { %s }')${BGreen}\n$ ${Color_Off}"

没问题