Hostname in shell (bash)?

Derrick Ryalls ryallsd at
Fri Feb 27 10:06:22 PST 2004

> Hi all,
> I searched the archives and documents on bash, but I can't figure out 
> how to put the hostname of the workstation I am on before the 
> $ of the 
> shell/command line.  Does anyone know how to add the hostname 
> (preferably the first part - i.e. www, db1, etc) to the 
> command line for 
> bash 2.x?

I have this in my .bashrc and .bash_profile files (\h is hostname):

# set prompt
PS1="===[\h][\u] \w # "

More information about the freebsd-questions mailing list