Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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                                       |....|

$ PS1="\xe2\x98\xa2\x0a"

I see my prompt appears like this:


...rather than showing the ☢ character. What am I doing wrong?

share|improve this question
up vote 10 down vote accepted

That's not valid bash escape syntax for simple double quotes. Try instead

PS1=$'\xe2\x98\xa2 '

This uses the special $'...' quoting that bash has and which does support ANSI C escapes. Note that the 0a 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.

share|improve this answer
*facepalm* why didn't I think of just trying the character!? – Naftuli Tzvi Kay Dec 20 '12 at 23:17

With recent versions of bash, you can also use the Unicode value:

PS1=$'\u2622 '

That way, it will get expanded/displayed properly (or at least not as bad) even if the local charset/encoding is not utf-8 (or it will cause bash to crash or output rubbish as I think I've uncovered a bug there).

share|improve this answer
Very nice. I was wondering if/why this feature wasn't present. Somehow, I feel better about including \u2622 than a raw Unicode character . – Naftuli Tzvi Kay Dec 21 '12 at 17:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.