[Cialug] bash return values [was: enter passwords less]

Daniel A. Ramaley daniel.ramaley at DRAKE.EDU
Mon Aug 27 10:21:39 CDT 2007


My prompt on all the systems i have accounts on looks like this:

PS1='\[\e[1m\][\u@\h \W]\$\[\e[0m\] '

That translates to:

[dramaley at dan ~]$ 

where "dramaley" is my account name "dan" is the hostname of the 
machine, and "~" is the directory i'm in right now (my home directory). 
The dollar sign changes to an octothorpe if i'm root, and the whole 
thing displays in a brighter white than most of the text on my terminal 
so it is easy for me to pick out command lines when i scroll back up 
through my terminal's buffer to read output that scrolled too fast. If 
you don't care for color, the functional part is simply '[\u@\h \W]\$ '

That prompt is for the bash shell. I assume other shells would have 
similar escape sequences to achieve similar effects.

On Monday 27 August 2007 09:26, Chris Freeman wrote:
>This is a very good point. In looking into the $HOSTNAME variables on
>systems I frequent, some of them use very long names or no $HOSTNAME
> (this on one particular AIX box). In that case, I could use
> `hostname` or `uname -h`.

------------------------------------------------------------------------
Dan Ramaley                            Dial Center 118, Drake University
Network Programmer/Analyst             2407 Carpenter Ave
+1 515 271-4540                        Des Moines IA 50311 USA


More information about the Cialug mailing list