> In bash it's possible to set the colour of the prompt [...]
> The question is, is there an easy way to do this under csh (that's the only
> shell we have use of here in work on the Sun boxen)
Look. Grr. This is the Wrong Thing. The Unix terminal interface has
been carefully crafted over the past 30 years to be independent of any
particular terminal type; with thousands of hours of effort going into
libraries like terminfo and curses. Putting terminal-specific codes
into your prompt (or elsewhere) is gratuitous breakage...
You should use the terminfo database to get the correct color-changing
codes for your terminal. Assuming TERM is set correctly (eg: to
"xterm-color"), you can use the "tput" command to get the correct
color-changing codes.
Red is color 1 in the ANSI color scheme, so for most terminals you can
do something like:
(sh-like version)
[ `tput colors` -gt 0 ] && PS1="`tput setaf 1`text here`tput setaf 0`"
(csh-like version)
if ( `tput colors` > 0 ) set prompt="`tput setaf 1`text here`tput setaf 0`"
Enjoy,
Colm
--
Colm Buckley B.A. B.F. # colm at tuatha.orgcolm.buckley at cs.tcd.ie
Department of Computer Science # +353 87 2469146 # whois cb3765
Trinity College, Dublin 2, Ireland. # http://www.tuatha.org/~colm/
Experience allows us to recognise our mistakes when we make them again.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!