How do I set my Terminal / shell PS1 prompt?
I have Mac OS X 10.5.8. When I try to change my unix shell prompt by putting the line:
export PS1='mac> '
into my .bash_profile, the prompt is changed but the cursor is in the first column (over the "m" of my prompt) and any typing overwrites the prompt.
You've got the basics nailed, though there's a ton of cool things you can do with your shell prompt above and beyond what you're trying to accomplish. The problem you're having is that I'm going to guess that you're using a different editor, not one within the Terminal.app environment on your Mac OS X system, and it's saving the file with the wrong kind of end-of-line sequence.
Many editors have configuration options on file saving that let you choose Mac or MSDOS line ending sequences: I'll bet you have it set for the wrong one for this specific file. Try doing this:
next time you're running in Terminal and I'm pretty confident that it'll display incorrectly.
The real solution is to either use an editor within the Terminal environment (the two main choices are "vi" and "emacs", both of which are quite sophisticated editors) or to use a third-party tool like BBEdit or TextWrangler, tools that understand the Linux environment lurking underneath your Mac OS X world.
Once you've nailed this problem, here are a few fun things you can do with the command prompt in Bash:
My command prompt, for example, is this:
PS1="\w (\!) \$ "
This gives me output like "~/bin (337) $ " when I'm in my "bin" directory, working. Experiment, play, you'll be surprised how helpful these can be once you really start digging into the command line!
More Useful Mac OS X Help Articles:
✔ Convert FLAC audio files to MP3 tracks on my Mac?
My son is in a band and he frequently sends me songs that they've recorded for me to hear what they're playing. Problem...✔ Audacity can't find LAME library, I can't save Mp3?
Hey Dave. I read your article Audacity can't save mp3 audio files and am still puzzled because I downloaded the LAME Mp3 converter...✔ How to remove Dashboard as a "space" in Mac OS X Spaces?
I'm a big fan of the Spaces utility in Mac OS X that lets me have multiple virtual screens [see Set Up Mac...✔ Best place to buy a cheap MacBook laptop?
Hi Dave. I am looking for two gently used MacBook laptops for my teen daughters. Personal computers would greatly facilitate their studies as...✔ File too big error copying to USB flash drive on my Mac?
I'm baffled. I have a 16GB Kingston USB flash drive that I use on my Mac system and I'm trying to copy a...
Let's stay in touch!
Sign up for my weekly AskDaveTaylor Newsletter and you'll receive even more tech and gadget help right to your inbox, along with exclusive news and industry updates. It's good stuff. I promise!
I do have a comment, now that you mention it!
Check This Out Too...
Look for Answers
All Our Categories
Apple iPad Help
Articles and Reviews
Auctions and Online Shopping
Blogs and Blogging
Building Web Site Traffic
Business and Management
Computer and Internet Basics
d) None of the Above
Google Gmail Help
Google Plus Help
Industry News and Trade Shows
iPhone and Cell Phone Help
iPod, Sony PSP and MP3 Player Help
Kindle Fire Help
Mac OS X Help
Pay Per Click (PPC) Advertising
Search Engine Optimization (SEO)
Shell Script Programming
Tech Support Video Help
The Writing Business
Twitter, LinkedIn and Social Network Help
Unix and Linux Help
Video Game Tips and Help
Windows PC Help
Find Me on Google+
ADT on G+