[X-Unix] .bash_profile

Stroller MacMonster at myrealbox.com
Fri Jan 9 04:27:44 PST 2004


On Jan 9, 2004, at 9:50 am, Simon Forster wrote:

> Just out of curiosity, what sort of changes are people making to their 
> shell environment by changing .bash_profile? Really I'm just after 
> hints and tips which could make my command line experience easier.

My Gentoo Linux box comes with this in the default /etc/profile (which 
I think is sourced by Bash on that system); it gives users a pretty 
coloured command prompt:

   if [ `/usr/bin/whoami` = 'root' ]
   then
         # Do not set PS1 for dumb terminals
         if [ "$TERM" != 'dumb'  ] && [ -n "$BASH" ]
         then
                 export PS1='\[\033[01;31m\]\h \[\033[01;34m\]\W \$ 
\[\033[00m\]'
         fi
         export PATH="/bin:/sbin:/usr/bin:/usr/sbin:${ROOTPATH}"
   else
         # Do not set PS1 for dumb terminals
         if [ "$TERM" != 'dumb'  ] && [ -n "$BASH" ]
         then
                 export PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\W \$ 
\[\033[00m\]'
         fi
         export PATH="/bin:/usr/bin:${PATH}"
   fi

I like to change the colours on different systems, so I can see 
immediately which box I'm shelled into. My  prompt on my Mac is much 
simpler (and stored in .bashrc):
$ cat .bashrc
PS1="\! \w \$

This gives me just the history number & the current working directory. 
I think my first Unix box, an SGI Indigo was set up like this out of 
the box; I really like having the history number shown as it allows me 
more easily to do history-expansions such as "!!:0 !-3:1 !403:$".

Hope this is of interest,

Stroller.



More information about the X-Unix mailing list