LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-29-2010, 04:11 PM   #1
jholp
LQ Newbie
 
Registered: Jan 2010
Posts: 13

Rep: Reputation: 0
Need dynamic prompt


Please be patient with me.

I am trying to set a dynamic PROMPT to show me where I am. I have tried the following but it is not working.

PS1=[h::\u:\w]> ;export PS1

my prompt should look like;

redhat5::jholp:/home.jholp>

But it is not working.

Can yo give me the syntax so my prompt tells me which machine I am
on, who I am on as, and where I am in the directory structure.

This way I do not have to do pwd to see where I am

Once the syntax is correct I place it in .bash_profiel or .profile?

I am using Red Hat 5.2 Server distribution


Thanks,

John
 
Old 01-29-2010, 04:18 PM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
Try something along these lines:

Code:
export PS1='[\h:\u:\w]\$ '
My custom prompt lives in my .bashrc

Edit: I really would suggest keeping the \$ as it changes based on if you're root or non-root. Helps keep track, but you could put a > in instead if you really feel it has to have a > at the end. To get more or a less exactly what you want would be:

Code:
 
export PS1='[\h::\u:\w]> '

Last edited by rweaver; 01-29-2010 at 04:23 PM.
 
Old 01-30-2010, 06:46 AM   #3
jholp
LQ Newbie
 
Registered: Jan 2010
Posts: 13

Original Poster
Rep: Reputation: 0
Mr. Weaver,

Thanks, it works perfect. I forgot the single ' is what gives the interpretation of u::, u: etc., etc.

John
 
Old 02-01-2010, 04:47 PM   #4
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
Glad to be of assistance
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting 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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Restricting Dynamic Ipaddress by based on Dynamic DNS host names karthik9110 Linux - Newbie 5 12-14-2009 12:46 AM
passing parameters from a unix shell prompt into a windows cmd.exe prompt nano2 Programming 1 09-01-2009 12:26 PM
Getting Dynamic IP eponymous Linux - Networking 5 10-09-2004 07:08 PM
Dynamic name resolution for dynamic IP merlin740 Linux - Software 2 10-04-2004 06:56 PM
Dynamic IP? Gerardoj Linux - Networking 5 05-27-2003 03:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration