Operating System - HP-UX
1834150 Members
2980 Online
110064 Solutions
New Discussion

Change Command Prompt to >

 
SOLVED
Go to solution
bbutler3295_1
Occasional Contributor

Change Command Prompt to >

Command to change the promt from hostname# to show the full path to the directory that you are in. example
Currently is displays like this "hostname#"
i would like the display to show the full path like this.
"hostname:/var/spool/cron>"

Thanks
BB
10 REPLIES 10
Vicente Sanchez_3
Respected Contributor

Re: Change Command Prompt to >

Hi,

Try this:

hostname:$PWD>

Regards, Vicente.
Pete Randall
Outstanding Contributor

Re: Change Command Prompt to >

export PS1="`hostname`(!)`pwd`# "

Pete

Pete
RAC_1
Honored Contributor

Re: Change Command Prompt to >

export PS1='hostname:$PWD>'
There is no substitute to HARDWORK
Pete Randall
Outstanding Contributor

Re: Change Command Prompt to >

Oops, minor tuning:

export PS1="`hostname`:`pwd`> "

Pete

Pete
melvyn burnard
Honored Contributor
Solution

Re: Change Command Prompt to >

in your .profile file add:
PS1="$(hostname):\$PWD\>"
export HISTFILE PS1

My house is the bank's, my money the wife's, But my opinions belong to me, not HP!
bbutler3295_1
Occasional Contributor

Re: Change Command Prompt to >

would it be correct to # out any existing export command for PS1

this is how it looks now
--------------------------
PS1="$(hostname):\$PWD\>"
export HISTFILE PS1

#export PS1="$(hostname)# "
--------------------------
John Poff
Honored Contributor

Re: Change Command Prompt to >

Hi,

You could comment out the old line, but if you don't think you will ever use it again, delete it.

I was taught shell scripting by the most intelligent person I've ever met in my life and one of the real computing wizards of our time. His philosophy was that a script (which a .profile is) should contain just exactly what it needs to run and it should look like it was written just to do what it is supposed to do, without a lot of commented out old lines, whether it is the first version or the fiftieth. I say, if you are done with it, clean it up. :)

JP
Pete Randall
Outstanding Contributor

Re: Change Command Prompt to >

Sure, comment it out if you like, or just replace the existing - it's up to you.

Pete

Pete
Kim Kendall
Regular Advisor

Re: Change Command Prompt to >

If this is for the root account, I would recommend that you retain the pound sign so you have a visual reminder that this is the root account.

export PS1="[ `hostname`:\${PWD} ] #"

Re: Change Command Prompt to >

I recommend not using '>' in your command prompt.

If you want to repeat some or all of a command it is sometimes easier just to cut and paste it using the mouse, rather than using the command-line history. You will occasionally cut and paste the wrong text, due to clumsiness, without noticing. When you press ENTER, you issue an unintended command. Usually, the unintended command will be invalid, and no harm will be done. But if you use '>' in your prompt, the unintended command can be a valid command with redirection. You could accidently overwrite a file with garbage.

Using a # in your command prompt is better because # starts a comment, so pasting it accidently usually results in a truncated, invalid commmand.

I also recommend against including the name of the current working directory in your prompt. Including it seems popular and useful, but consider what happens if your current working directory is deep in a directory tree. The prompt will occupy most of the command line. Interpreting the text displayed in the command window will be much harder because commands are more likely to be split over several lines, and because the numerous repetitions of the long directory name are distracting.