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

Ste*_*ani 3 bash ps1 windows-10

这是我设置我的bash PS1的脚本

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

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

# Bold
BBlack="\[\033[1;30m\]"       # Black
BRed="\[\033[1;31m\]"         # Red
BGreen="\[\033[1;32m\]"       # Green
BYellow="\[\033[1;33m\]"      # Yellow
BBlue="\[\033[1;34m\]"        # Blue
BPurple="\[\033[1;35m\]"      # Purple
BCyan="\[\033[1;36m\]"        # Cyan
BWhite="\[\033[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$ "
Run Code Online (Sandbox Code Playgroud)

直到昨天我决定将我的笔记本电脑更新到Windows 10时它才完美运行.

现在它抛出了这个错误:

bash: command substitution: line 1: syntax error near unexpected token `)'
bash: command substitution: line 1: `__git_ps1 ' { %s }')'
Run Code Online (Sandbox Code Playgroud)

有什么导致这个错误的想法吗?

Ste*_*ani 11

问题是ps1中的结束新行.我在这里找到了解决方案.将我的PS1改为:

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