Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PS1 bash command substitution not working on windows 10

This is my script that sets up my 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$ "

It was working perfectly until yesterday when I decided to update my laptop to windows 10.

Now it throws this error:

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

Any idea on what is causing this error?

like image 935
StefanoGermani Avatar asked Oct 19 '15 17:10

StefanoGermani


People also ask

Why can't I use Bash command on CMD or PowerShell?

So, when I try to use the bash command on cmd or PowerShell, I get errors saying that there is no such thing. bash : The term 'bash' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Is there a Bash command in Windows 10?

There are no results for bash commands in Windows 10 which don't include some sort of Linux installation in Windows. If someone knows, then maybe at Stackoverflow. I am not contradicting your experience of what used to be, but can't reproduce it, as on none of my PCs any bash command works in Windows.

Is Bash a cmdlet name?

bash : The term 'bash' is not recognized as the name of a cmdlet, function, script file, or operable program.


1 Answers

The problem is the ending new line inside the ps1. I found the solution here. Changed my PS1 to:

PS1="\n${BBlack}\u@\h ${BRed}\w${BYellow}\$(__git_ps1 ' { %s }')${BGreen}"$'\n$ '
like image 189
StefanoGermani Avatar answered Sep 18 '22 04:09

StefanoGermani