Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I just ran across a screenshot of someone's terminal:

enter image description here

Is there a list of all of the characters which can be used in a Bash prompt, or can someone get me the character for the star and the right arrow?

share|improve this question

2 Answers 2

up vote 47 down vote accepted

You can use any printable character, bash doesn't mind. You'll probably want to configure your terminal to support Unicode (in the form of UTF-8).

There are a lot of characters in Unicode, so here are a few tips to help you search through the Unicode charts:

  • You can try to draw the character on Shapecatcher. It tries to recognize a Unicode character in what you draw.
  • You can try to figure out which block the character is in. For example, that weird-looking symbol and that star would be in a block of miscellaneous symbols; characters like Ǫ and ı are latin letters with modifiers; is a mathematical symbol, and so on.
  • You can try to think of a word in the description of the character and look for it in a list of unicode symbol names and descriptions. Gucharmap or Kcharselect can help.

P.S. On Shapecatcher, I got U+2234 THEREFORE for , U+2192 RIGHTWARDS ARROW for , U+263F MERCURY for and U+2605 BLACK STAR for .

In a bash script, up to bash 4.1, you can write a byte by its code point, but not a character. If you want to avoid non-ASCII characters to make your .bashrc resilient to reencodings, you'll need to enter the bytes corresponding to these characters in the UTF-8 encoding. You can see the hexidecimal values by running echo ∴ → ☿ ★ | hexdump -C in a UTF-8 terminal, e.g. is encoded by \xe2\x88\xb4 in UTF-8.

if [[ $LC_CTYPE =~ \.[Uu][Tt][Ff]-?8 ]]; then
  PS1=$'\\[\e[31m\\]\xe2\x88\xb4\\[\e[0m\\]\n\xe2\x86\x92 \xe2\x98\xbf \\~ \\[\e[31m\\]\xe2\x98\x85 $? \\[\e[0m\\]'
end

Since bash 4.2, you can use \u followed by 4 hexadecimal digits in a $'…' string.

  PS1=$'\\[\e[31m\\]\u2234\\[\e[0m\\]\n\u2192 \u263f \\~ \\[\e[31m\\]\u2605 $? \\[\e[0m\\]'
share|improve this answer
    
Hmm. When I run echo ★ | hexdump -C1, I get: hexdump: invalid option -- '1'. Will it still work without the 1 in the invocation? –  Naftuli Tzvi Kay Dec 2 '11 at 1:47
1  
@TKKocheran That 1 was a typo, it's just hexdump -C (or hd for short on some systems). –  Gilles Dec 2 '11 at 10:46
    
Thanks, just wanted to be sure. –  Naftuli Tzvi Kay Dec 2 '11 at 20:08
    
Also, you could do : PS1=$'\u2234\u2192\u263f\u2605' feels easier to maintain :-) –  mat Mar 20 '13 at 11:14
    
@mat Indeed, thanks (but only since bash 4.2). –  Gilles Mar 20 '13 at 11:40

You can find the unicode symbols on lots of sites, like this one: http://panmental.de/symbols/info.htm

You just have to make sure that your term supports UTF-8.

share|improve this answer
    
How would I escape one of these characters? Ie \u27A4 –  Naftuli Tzvi Kay Dec 2 '11 at 0:01
2  
See @Gilles answer, or this: stackoverflow.com/questions/602912/… –  jasonwryan Dec 2 '11 at 0:45
    
You can see all 65000+ unicode points at utf8-chartable.de (In the context of code point values "utf8" is synonymous with "unicode".) –  goldilocks Mar 20 '13 at 12:02

Your Answer

 
discard

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.