
How do I set the shell prompt in Mac OS X Terminal?I'm new to Mac, last Apple I owned was a IIe in the 80's. This question is related to your book Learning Unix for Mac OS X Tiger book, page 41 "Changing the Command Prompt. In this section you give the following command for changing the prompt: PS1= "? " I typed this, but got the following response from the terminal window: -bash: ? : command not found What am I doing wrong? I can see exactly what the shell is complaining about, and I'll end any suspense by saying that you need to ensure that you never have superfluous spaces in the commands you type into Terminal or anywhere on a Unix command line. There's a world of different to the Bash shell between: PS1= "? " and PS1="? " Can you see where the extra space snuck in? Take it out, and you'll be sitting pretty with your prompt customization. In general, this is a very common glitch for Linux and Mac command line users, one that can trip up even experienced users. If you're in doubt in the future, make sure that you eyeball the command you expect to have work and try removing any extra spaces, just to see if it'll work better. My command prompt on my own Mac system, by the way, is: PS1="\W \! $ " Try it, you'll find it a pretty darn useful prompt, especially as you get more used to working with command history. Also, it's important that you're in the correct shell when you're trying to set a command prompt because the C Shell and its family of command shells use a different notation. Try using the PS1="? " notation shown above and you're likely to get csh: PS1=? : Command not found. instead of a new prompt. Csh uses a very different syntax for setting shell level variables, actually. To accomplish the same result in the C Shell, you'd use this: set prompt="? " Again, as with Bash, Csh also has lots of useful shortcuts too. In both cases, a check of the man page (use man bash for Bash, or man csh for Csh, for example) will reveal the many useful ways you can customize your prompt. Drop the customization into your .profile or .login, depending on your shell, and you'll be a happy command line user forever more! Hope that helps you out!
Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Simpy.
Categorized:
Mac OS X Help
, Unix and Linux Help
(Article 4181)
Tagged: Previous: What are RAR files for my Sony PSP? Next: What do XGA, SXGA, WVA and "Wide Angle" mean? Subscribe!
Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader. Hi, hi sir, Please answer me Ajay, yes. Instead of START -> Run... you have Applications -> Utilities -> Terminal.app Posted by: Dave Taylor at April 27, 2007 5:52 AMDave, I'm a big fan of yours and hope to get out to the Colorado area soon; however, I've run into a problem with my lovely OS X terminal. I use it daily and love to use ssh within it, but now it seems that anytime I launch my terminal I find myself getting the following situation: ------------------------------------------ Last login: DOW MON ## HH:MM:SS on ttyp1 ------------------------------------------ I can't figure out for the life of me where it is automatically retrieving the ssh 192.168.0.70 command. I've used this command before via QuickSilver and wonder if this may be the cause but I can't identify where to get rid of within there. I've tried everything I can think of for several hours now and would _really_ love to not have to hit CTL+C everytime I load up my terminal window. Any help is greatly appreciated!!! Thanks, Steven Steven, look in your ~/.profile or ~/.bashrc (if you're running bash). I'd do this, actually: $ cd and see if it pinpoints that command anywhere. Good luck! Posted by: Dave Taylor at June 13, 2007 12:46 AMit would be nice if you could show what the symbols mean. Personally, I like to see the whole directory branch otherwise it is easy to get lost. How would a person do that? Posted by: chris at September 3, 2007 8:41 PMI have a lot to say, but ...
I do have a comment, now that you mention it!
|
Search
Find just the answers you seek from among our 1700+ free tech support articles by using our Lijit search engine.
Help!
Subscribe to
Ask Dave Taylor!
Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.
Articles and Reviews
Auctions and Online Shopping Blogs and RSS Feeds Building Web site traffic Business and Management Cell Phones and Mobile Phones CGI Scripts and Web Site Programming Computer and Internet Basics d) None of the Above HTML and CSS Mac OS X Help MySpace, Facebook, Twitter and Social Network Help Pay Per Click (PPC) Search Engine Optimization Shell Script Programming Sony PSP, MP3 Players, Etc. The Writing Business Unix and Linux Help Video Game Tips and Help Windows Help
Recent Entries
Join the List!
Book Links
|