Discussion Locked

Changing prompt

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I would like to be able to show the current dirrectory and the path back to the top of the tree. I know I can type 'pwd' at the command line and have this type out, but I would like it displayed at the prompt.

Similar to the default setting for DOS, (Prompt = $p$g)

I am using Red Hat.

5 replies

by peter marshall

Using Red Hat I assume that you are using the bash shell

(in this case go to your home directory)
cd
(Open the .bashrc file for editing.)
vi .bashrc
(insert the following line)
PS1='$PWD$ '
(Save the file and reread it)
. ./.bashrc
(If your user name is peter your prompt will look like this)
/home/peter$
(There will be a space after the $ sign)

The syntax of this line is as follows
PS1 is a variable for the prompt
= Assign the value
'$PWD$ '
a string composed of the currentvalue of the variable PWD concatinated with a $ symbol followed by a space.

If you are using a different shell you will need to put this line in the appropriate configuration file in your home directory

Korn shell .kshrc
Borne Shell .profile
C Shell .cshrc (Different Syntax)

Cheers

Peter

by spidererrol

Assuming your shell is bash, add this line to ".bash_profile" in your home directory:
PS1='[\u@\h \w]\$ ' export PS1

This line can also be typed at the prompt to test it.

More information about these prompt codes can be found in "man bash" atthe command line, and finding the "PROMPTING" section.

This discussion is closed to new replies.