Recent Articles


Bug in Shell Script Using awk to Read /etc/passwd?
In your book Wicked Cool Shell Scripts, on p. 115, Script #40 Reporting Disk Hogs, on the 8th line the second part of the line reads...

Managing A Worldwide Print Infrastructure From...

Company - This US based company is one of the world's largest manufacturers of automotive parts and sub-assemblies in the world. Their customers include: BMW, Daimler-Chrysler, Ford, General Motors, Honda...

Linux Training: Courses vs. Videos
Beware of loosing your shirt going to a Linux training course taught in a classroom. You just might regret spending your hard-earned cash - and likely won't be able to get it back! As a new Linux user, you'll find that...

System Administrator And System Engineer Jobs
Systems Administrators are expected to be efficient in diagnosing and fixing problems fast and with accuracy. It is essential for a system administrator to have a substantial understanding of various programming languages used for computing various tasks. In addition...

A Quick Way to OpenBSD and How to Use it
I have been a BSD user since the late 1990's. I made my own FreeBSD distro - 1fcdbsd or One Floppy CD Audio and MP3 Player (http://www.freebsd.nfo.sk/), and I gained some experience with the BSD world, which rather...



07.17.07


How Do I Change My PS1 Command Prompt In Bash?

By Dave Taylor

I Have read about 15 chapters of your book (Teach Yourself UI hNIX in 24 Hours) so far. We are using vi. On the PS1 command, how do I see what is in it so I can add to it and not change what is already there? We are using bash.

What I see now is: ctdaywbsdv:/u/gwilki$

When I enter ‘echo $PS1' I get: $ \[\e[0m\]

How do I keep the above and add the histcmd option? What does the \e and 0m\ mean? What do the [] the square brackets mean? I can't find a man page for PS1. How do I find the rest of the options for this PS1?


You're right that there's no man page for the PS1 prompt setting in Bash, but the bash man page itself (type man bash) is incredibly long, and one section explains all the features and capabilities of the PS1 prompt variable. In that it notes, for example, that:
The value of this parameter is expanded (see PROMPTING below) and used as the primary prompt string. The default value is \s-\v\$
Going down to the section labeled PROMPTING, it explains all the different variables you can utilize to set or customize your own Bash prompt. It's incredibly long:

View Table

Download Web CEO 7 Free Edition Click Here

To see the current value of your prompt, just type echo $PS1 in the Bash shell. To change it, simply change the value of that variable. To make the change automatic each time you log in, add that to your ~/.profile and it's done.

Now you have enough information to learn what the \e and \0m mean too. The former is the ASCII escape character and is likely being used to start a sequence to put your prompt in bold or inverse video, and \0m is indeed the sequence required to do just that, it's the \000 format being used.

I hope that helps you fine-tune your Bash prompt as needed!

Comments



About the Author:
Dave Taylor has been involved with the Internet since 1980 and is internationally 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 strategic 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/


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

UnixProNews 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 ITCertificationNews.com


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

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


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