Operating System - Tru64 Unix
1748112 Members
3274 Online
108758 Solutions
New Discussion юеВ

Re: How to display hostname in front of the "#"

 
SOLVED
Go to solution
Rambo_1
Regular Advisor

How to display hostname in front of the "#"

Hi ,
where should I edit ?

Thanks
6 REPLIES 6
Ravi_8
Honored Contributor

Re: How to display hostname in front of the "#"

Hi

Login as root, open the .profile file existing under /

at the end of the .profile file add

PS1=#`hostname`

save and close the file

#. ./.profile

now you prompt will be
#


never give up
Shaikh Imran
Honored Contributor

Re: How to display hostname in front of the "#"

Hi,
In addition to above.
Don't forget use export PS1

Regards,


I'll sleep when i am dead.
Ravi_8
Honored Contributor

Re: How to display hostname in front of the "#"

Hi,

no need to export, as the .profile will be executed whenever the user login
never give up
G. Vrijhoeven
Honored Contributor

Re: How to display hostname in front of the "#"

Hi,

I would go for:

PS1='prc60b22:$PWD # '

This adds the server name and displays the current dir.

HTH,

Gideon
G. Vrijhoeven
Honored Contributor
Solution

Re: How to display hostname in front of the "#"

Sorrie:

PS1=`hostname`:'$PWD # '

Regards,

Gideon
Han Pilmeyer
Esteemed Contributor

Re: How to display hostname in front of the "#"

Well... all of this assumes that the author is running sh, ksh, bash or something similar, which isn't necessarily the case.

You probably want to do something as suggested in the previous replies. However if you're not interested in the fully qualified domain name, I suggest something like this:

typeset host=$(uname -n)
PS1="${host%%.*}# "

Possibly in combination with other things of course. Similar solutions are possible on csh, tcsh, etc. The man pages for the shells are usually helpful.