Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > ★ Unicode Characters in Terminal Prompt?‽

★ Unicode Characters in Terminal Prompt?‽
Thread Tools
Mac Elite
Join Date: Mar 2002
Status: Offline
Reply With Quote
Oct 15, 2008, 03:49 AM
 
I’ve recently updated my Bash installation to version 3.2.39(1)-release, updated the coreutils and followed the other steps necessary to enable me to type Unicode characters in Terminal, but I haven’t been able to work out how to get ★s, ♥s, s and other symbols to show up in my shell prompt.

Grateful for any suggestions. ☺✌
     
Posting Junkie
Join Date: Dec 2000
Status: Offline
Reply With Quote
Oct 16, 2008, 06:51 PM
 
This isn't really a development issue, so I'm not really sure this is the right forum for it.

However, you can go to Preferences window, then click the Advanced tab, and make sure the encoding is set to UTF-8. This should at least cause filenames to show up correctly when displayed by the 'ls' program. For other cases, it will depend on whether the program outputs in UTF-8 or something else - if a particular tool you're using outputs text in some other encoding, you may want to change the encoding to that instead.

Ticking sound coming from a .pkg package? Don't let the .bom go off! Inspect it first with Pacifist. Macworld - five mice!
     
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status: Offline
Reply With Quote
Oct 16, 2008, 06:58 PM
 
You don't need to upgrade anything for those to work. You just have to make sure that the font you are using in the teminal supports that character.

If you go to the edit menu and select "Special Characters" you can then use that to "type" them into the terminal window. I was able to find everything but the Apple character (I did not search hard), and using bash all you have to do is:

PS1='<<insert character here>>'
     
Mac Elite
Join Date: Mar 2002
Status: Offline
Reply With Quote
Oct 17, 2008, 03:07 AM
 
They do show up correctly. Everywhere, in fact, just not in the shell prompt, where I get two question marks instead of the intended character.

Oddly, pico (the editor I’d been using) let me type in the characters when I was editing my /etc/motd file, but not when editing .bashrc, where I got the ‘??’ again.

Now, I just edited the .bashrc file in TextWrangler, typing in the ★ character, and saving as UTF-8. When I open the file in pico, the character shows correctly in there, but in the prompt it’s ‘??’ instead.

The farthest I’ve gotten with this is typing in the character using the ‘Unicode Hex Input’ layout. This actually gets the ★ character into the prompt, preceded by a question mark and a space I didn’t type. Moreover, doing it this way gets the following printed to the screen before the prompt:

Code:
declare -x CLICOLOR="1" declare -x HOME="/Volumes/Data/Users/red" declare -x LC_CTYPE="en_US.UTF-8" declare -x LSCOLORS="dxfxcxdxbxegedabagacad" declare -x OLDPWD declare -x PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/texbin:/usr/local/bin" declare -x PWD="/Volumes/Data/Users/red" declare -x SECURITYSESSIONID="20fc50" declare -x SHELL="/bin/sh" declare -x SHLVL="1" declare -x TERM="xterm-color" declare -x TERM_PROGRAM="Apple_Terminal" declare -x TERM_PROGRAM_VERSION="100.1.8" declare -x USER="red" declare -x __CF_USER_TEXT_ENCODING="0x1F5:0:0"
     
Posting Junkie
Join Date: Dec 2000
Status: Offline
Reply With Quote
Oct 17, 2008, 03:33 AM
 
Putting a star character in the bash prompt works for me:

Code:
PS1="★ "
Then, when opening a new Terminal window, I get:

Code:
Last login: Fri Oct 17 03:33:54 on ttys000 ★ echo "hello world" hello world ★

Ticking sound coming from a .pkg package? Don't let the .bom go off! Inspect it first with Pacifist. Macworld - five mice!
     
Mac Elite
Join Date: Mar 2002
Status: Offline
Reply With Quote
Oct 17, 2008, 04:20 AM
 
Maybe it’s got something to do with my old version of Terminal.

Finally got it working. Opened .bashrc in TextWrangler, switched to Unicode Hex input method, typed ⌥2605 to get the ★ symbol, saved as UTF-8.

Code:
export PS1='\[\e[1;31m\][\A]\[\e[1;35m\][\u]\e[1;32m\][\w]\[\e[0m\]★'
Thanks for the help.
     
Mac Elite
Join Date: Oct 2000
Location: Seattle
Status: Offline
Reply With Quote
Oct 17, 2008, 05:18 AM
 
Originally Posted by CharlesS View Post
This isn't really a development issue, so I'm not really sure this is the right forum for it.
This forum is where the smart people hang out!
(Last edited by Gavin; Oct 17, 2008 at 05:27 AM. )
You can take the dude out of So Cal, but you can't take the dude outta the dude, dude!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:51 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2