Bash PS1 shows $ instead of # for root

When you enter the root folder, the default prompt for the echo \s-\v\$is displayed as bash-4.2#. I'm trying to play around with a bash prompt so that it displays the working directory. export PS1="\w \$".

It is displayed correctly on the right, however, the character is \$not converted to #, although mine $UIDis 0, which leads to the victory in skipping the user's character \u. Is there anything extra that I have to add, or does this symbol not work if I export it?

+4
source share
3 answers
export PS1="\w \$"

$PS1 \w \$, \w $, , :

echo "$PS1"

:

export PS1='\w \$'
+6

:

export PS1="\w \\$"

, . . : cyberciti

+1

the trait will disappear in "". Just need to add another one to save it. Or

export PS1='\w \$'

or

export PS1="\w \\$"

works for you.

You can combine "and". For instance:

export PS1="\w blabla"'\$'
+1
source

Source: https://habr.com/ru/post/1538899/


All Articles