Click to Play

Is Your Site Secure?
The Internet is an amazing place, but it can also be very dangerous. Many times, webmasters are so focused on issues such as duplicate content that they neglect...

Recent Articles

Splashtop Creator Joins Linux Foundation
The Linux Foundation has announced that DeviceVM has become its newest member. DeviceVM is the creator of the Splashtop instant-on platform, which is powered...

KVM Dirvers Bring More Stability To Linux OS
News that paravirtual drivers for Windows on KVM have been released by Red Hat isn't, and shouldn't be a big deal. In the virtualization wars, it is clear that...

LinuxCon Is Fast Approaching, Are You Ready?
Amanda McPherson's post titled "How to Survive LinuxCon" made me realize that LinuxCon is less than six weeks away. While there is a lot of excitement around Linus speaking at LinuxCon, there are several...

Microsoft Clarifies The Reasoning For Its Open...
Microsoft has responded to claims that their Linux Integration Components (LIC) were only contributed under the GPLv2 after being out of compliance...

Understanding The Difference Between Linux...
I was using Sun Microsystems Solaris operating system at school for the last month. I was also told by my professor that it was also Unix operating system. Are Unix operating system. Are Unix and Solaris the same...


10.14.09

Understanding Linux Components Within A Mac Shell

By Dave Taylor

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.

Dave's Answer:

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:

cat ~/.bash_profile

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:

SequenceExplanation
\hthe hostname up to the first `.'
\Hthe hostname
\tthe current time in 24-hour HH:MM:SS format
\Tthe current time in 12-hour HH:MM:SS format
\@the current time in 12-hour am/pm format
\uthe username of the current user
\wthe current working directory, with $HOME abbreviated with a tilde
\Wthe basename of the current working directory, with $HOME abbreviated with a tilde
\!the history number of this command
\$if the effective UID is 0, a #, otherwise a $

My command prompt, for example, is this:

PS1="\w (\!) \$ "

Comments


About the Author:
Dave Taylor is known as an expert on both business and technology issues. Holder of an MSEd and MBA, author of twenty books and founder of four startups, he also runs a marketing company and consults with firms seeking the best approach to working with weblogs and social networks. Dave is an award-winning speaker and frequent guest on radio and podcast programs.

AskDaveTaylor.com
http://www.intuitive.com/blog/
LinuxProNews is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
DatabaseProNews.com SQLProNews.com
ITcertificationNews.com SysAdminNews.com
LinuxProNews.com WirelessProNews.com
CProgrammingTrends.com DevWebPro.com


About LinuxProNews
LinuxProNews is a collection of news and commentary designed to keep you in step with the ever evolving landscape of Linux environments. Opensource News and Advice for Linux Professionals




-- LinuxProNews is an iEntry, Inc. publication --
iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509
2009 iEntry, Inc.  All Rights Reserved  Privacy Policy  Legal

archives | advertising info | news headlines | free newsletters | comments/feedback | submit article



Opensource News and Advice for Linux Professionals LinuxProNews News Archives About Us Feedback LinuxProNews Home Page About Article Archive News Downloads WebProWorld Forums Jayde iEntry Advertise Contact