I'm trying to customize my Bash prompt with Unicode characters and I'm having a bit of trouble. If I try to include a Unicode character like this:
$ echo ☢ | hexdump -C
00000000 e2 98 a2 0a |....|
00000004
$ PS1="\xe2\x98\xa2\x0a"
I see my prompt appears like this:
\xe2\x98\xa2\x0a
…rather than showing the ☢ character. What am I doing wrong?
Best Answer
That's not valid
bash
escape syntax for simple double quotes. Try insteadThis uses the special
$'...'
quoting thatbash
has and which does support ANSI C escapes. Note that the0a
is just linefeed (newline character) and I doubt you want that, so I took the liberty of replacing it with a space above.Of course, instead of going through the entire rigamarole of finding the UTF-8 encoding, and then typing out the escapes, you could just use the raw character itself (
PS1='☢ '
) and it would still work.