puflogh300X74.gif

Polarwave's OpenBSD
Tips and Tricks for Newbies

| XTerm Color |

| Home | Tips and Tricks | Links | News Feeds | Fun | Contact | Blog (Opens in New Page) |


Color for XTerm Apps

I was getting tired of my plain old blue background and white text xterm on my desktop
and wanted to spruce it up a little. I read up on xterm(1), Googled around and had a look
at other folks' .kshrc files, and started experimenting with it. I also wanted my .muttrc
colors to show up when I was reading my email, independently of what my normal xterm
colors are, and I had a time figuring it out, but I finally put it all together and came up
with a working solution. In my .kshrc file, putting

TERM=xterm-color
and adding it to my line of exports didn't seem to solve the problem. I fiddled around with
.Xdefaults, as I'm using Xorg. I mention that since with the old XFree86 the referenced file
was .Xresources. I got the colors the way I wanted them, restarted X and I still didn't have
the colors I wanted. Here's what my cut down version of .Xdefaults looks like:
! $XTermId: XTerm-col.ad,v 1.19 2005/09/18 23:48:12 tom Exp $
! $XFree86: xc/programs/xterm/XTerm-col.ad,v 3.7 2005/09/18
  23:48:12 dickey Exp $

include: "XTerm"

!XTERM*loginShell: true
XTerm*font: -schumacher-clean-medium-*-normal-*-13-*-*-75-*-60-*-*
*VT100*colorMode: on
*VT100*boldColors: on
*VT100*dynamicColors: on

*VT100*foreground: cyan
*VT100*background: gray15

*VT100*colorULMode: on
*VT100*colorUL: yellow

*VT100*underLine: on

*VT100*colorBDMode: on
*VT100*colorBD: yellow3

! These are the 8 ANSI colors and their bright equivalents.
! Depending on other resource settings, xterm may use the
! bright colors when displaying bold text
! (see the boldColors resource).
*VT100*color0: black
*VT100*color1: red3
*VT100*color2: green3
*VT100*color3: yellow3
*VT100*color4: blue2
*VT100*color5: magenta3
*VT100*color6: cyan3
*VT100*color7: gray90
*VT100*color8: gray50
*VT100*color9: red
*VT100*color10: green
*VT100*color11: yellow
*VT100*color12: rgb:5c/5c/ff
*VT100*color13: magenta
*VT100*color14: cyan
*VT100*color15: white
*VT100*color16: gray15

#if PLANES > 8
! Color the popup menus and the menubar to match:
*SimpleMenu.*.background: AntiqueWhite
*SimpleMenu.*.foreground: gray15

! Color the menubar to match:
!*.Form.menubar.*.background: AntiqueWhite
!*.Form.menubar.*.foreground: gray15
!*.Form.background: AntiqueWhite

*VT100.scrollbar.thumb:         vlines2
*VT100.scrollbar.width:         14
*VT100.scrollbar.background:    gray60
*VT100.scrollbar.foreground:    rgb:a/5/5
*VT100.scrollbar.borderWidth:   2
#endif
If you look at your .Xdefaults you're going to see quite a bit more than that in all
probability, but if you notice, a good majority of the entries are preceded by an
! symbol. That's how items are commented in .Xdefaults, which means anything
to the right of the ! has no effect whatsoever.

Finally, from the command line,
echo $TERM
and getting VT220 back, is what put me on to the answer. I reopened .kshrc
and changed
if [ -x /usr/bin/tset ]; then
eval `/usr/bin/tset -sQ \vt220`
to
if [ -x /usr/bin/tset ]; then
eval `/usr/bin/tset -sQ \xterm-color`
and that took care of the problem. You know, whenever you make a change in .kshrc,
you can make the changes take effect without logging out and back in. From the
command line do
. ./.kshrc
and that'll get the new values into your environment. My .profile is very simple and
looks like this:
# $OpenBSD: dot.profile,v 1.4 2005/02/16 06:56:57 matthieu Exp $
# sh/ksh initialization

ENV=$HOME/.kshrc
It simply sets my local environment to whatever is my .kshrc file which is a bit more
verbose, to say the least, and a lot of the stuff was put in there just for fun as you can
see, reading below. Here's what it looks like minus all self-incriminating cruft: :-)
# $OpenBSD: dot.profile,v 1.4 2005/02/16 06:56:57 matthieu Exp $
# sh/ksh initialization

HISTSIZE=100
HISTFILE=.ksh_history
export HISTSIZE HISTFILE
PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:
/usr/local/bin:/usr/local/sbin:/usr/local/libexec:/usr/games:
/usr/local/jdk-1.4.2/bin:/usr/X11R6/lib/X11/fonts/TTF:.
HOSTNAME=myhostname.myisp.net
TERM=xterm-color
CVSROOT=/data/cvs
PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/4.2/packages/i386/
PS1="\n\H\n\t \d\n\u \w\n$ "
FCEDIT=vim
SANE_DEFAULT_DEVICE="epson:/dev/uscanner0"
JAVA_HOME=/usr/local/jdk-1.4.2/jre/lib/i386/
JAVA_FONTS=/usr/X11R6/lib/X11/fonts/TTF/
export PATH HOME PS1 TERM CVSROOT PKG_PATH FCEDIT SANE_DEFAULT_DEVICE
JAVA_HOME JAVA_FONTS HOSTNAME
umask 022
ulimit -c unlimited
alias x='exit'
alias lock='lock -np'
alias cte='crontab -e'
alias ctl='crontab -l |less'
alias obsdftp='ftp ftp://ftp.openbsd.org'
alias rebo='sudo reboot'
alias tata='sudo shutdown -h -p now'
alias kdhx='mplayer http://72.51.37.86:6540'
alias mpb='mplayer mms://radio.mpbonline.org/MPB_Live'
alias jazz1='mplayer http://wbez-sclo.streamguys.us/'
alias hub='ssh myusername@myotherbox'
alias hubx='ssh -x myusername@myotherbox'
alias winx='ssh -x myusername@mywinbox'
alias dy='ssh -x myusername@someftp.server.com'
alias flopffs='sudo mount -w -t ffs /dev/fd0a /flopffs'
alias uflopffs='sudo umount /flopffs'
alias flopdos='sudo mount -w -t msdos /dev/fd0a /flopdos'
alias uflopdos='sudo umount /flopdos'
alias kmntd='sudo kill -HUP `cat /var/run/mountd.pid`'
alias cp='cp -i'
alias rm='rm -i'
alias mv='mv -i'
alias md='mkdir'
alias mdp='mkdir -p'
alias rd='rmdir'
alias zap='rm -fP'
alias c='clear'
alias h='history'
alias allhist='fc -l -n 1 |less'
alias ls='colorls -G'
alias lsf='colorls -FG'
alias lall='ls -alhFG'
alias j='jobs'
alias umntnfs='sudo umount /mnt/nfs'
alias inmntcd1='sudo eject -t cd0 && sudo mount /mntcd1'
alias mntcd1='sudo mount /mntcd1'
alias umntcd1='sudo umount /mntcd1'
alias ejcd='sudo eject cd0'
alias incd='sudo eject -t cd0'
alias lookup='sudo /usr/libexex/locate.updatedb'
alias ispine='ps -U myusername | grep pine'
alias pine='~/pinez.sh pine /usr/local/bin/pine'
alias fdf='sudo fdformat /dev/fd0c'
alias nudos='sudo newfs_msdos /dev/rfd0c'
alias nuff='sudo newfs /dev/rfd0c'
alias fmm='fetchmail'
alias ducks='du -cks * |sort -rn |head -11'
alias startx='startx -- -depth 16'
alias lsmcd='sudo mount /mntcd1 && ls -ahlF /mntcd1 |less'
alias blankcd='sudo cdrecord blank=fast dev=/dev/rcd0c:0,0,0'
alias mybsd='cd ~/bsd/'
alias newprof='cd ~/ && . ./.profile'
alias msf='/usr/local/bin/gpg --decrypt /stuff/msf.txt.gpg |less'
alias pflog='sudo tcpdump -n -e -ttt -r /var/log/pflog |less'
alias nonum='fc -l -n $1'
alias tls='$HOME/bin/ftp-tls'
alias trak='sudo pfctl -t trackers -T show'
alias brut='sudo pfctl -t bruteforce -T show'
alias pfall='sudo pfctl -s all |less'
alias pfmem='sudo pfctl -s memory'
alias lynx='xterm -geometry 80x50 -bg gray15 -fg cyan -e lynx'
echo

if [ -x $HOME/useful.sh ]; then
$HOME/useful.sh
fi

if [ -x /usr/bin/tset ]; then
eval `/usr/bin/tset -sQ \xterm-color`
fi
There's a lot more there, especially aliases, than was really necessary for examples,
but I wanted to show that you can be very inventive with aliases, imaginative, and
create lots of time-saving shortcuts to get your everyday tasks done. For me, they
simply save me from a lot of typing. I guess the downside you might tend to forget
the commands they actually execute.

Last but not least are the color settings for mutt. In the first section under color:
color status brightwhite blue
mono message bold
color message white red
color error brightyellow red
color indicator white red
color tree brightmagenta default
color signature red default
color attachment brightyellow red
color search brightyellow red
color tilde brightmagenta default
color markers brightmagenta default
color quoted white default
color quoted1 magenta default
color quoted2 red default
color quoted3 green default
color quoted4 cyan default
color quoted5 blue default
color quoted6 magenta default
color quoted7 red default
color quoted8 green default
color quoted9 cyan default
color hdrdefault brightred default
color header brightyellow default "^(from):"
color header brightblue default "^(to):"
color header green default "^(subject):"
color body brightcyan default \ "((ftp|http|https)://|(file|mailto|news):|
www\\.)[-a-z@0-9_.:]*[a-z0-9](/[^][{} \t\n\r\"<>()]*[^][{} \t\n\r\"<>().,:])?"
color body brightcyan default "[-a-z_0-9.+]+@[-a-z_0-9.]+"
color body red default "(^| )\\*[-a-z0-9*]+\\*[,.?]?[ \n]"
Under the spam section:
color index magenta default "\(Resent-\)?Message-Id: <>"
color index magenta default "\(Resent-\)?Message-Id: '<.* .*>'"
color index magenta default "\(Resent-\)?Message-Id: localhost"
color index magenta default "! \(Resent-\)?Message-Id: @"
color index magenta default '~C Undisclosed.*Recipients'
And, under the gpg section:
color body brightblack cyan "^gpg: Signature made.*"
color body brightblack green "^gpg: Good signature from.*"
color body brightblack yellow "^gpg: Can't check signature.*"
color body brightblack yellow "^gpg: WARNING: .*"
color body brightwhite red "^gpg: BAD signature from.*"
So, maybe that'll give you a leg up on creating some aesthetically pleasing
X desktop eye candy. Personally, I like fluxbox. Lightweight, low overhead,
no unneeded crap, and very customizable.

Cheers!

Back to Tips and Tricks
Home

Delicious Bookmark this on Delicious

No affiliation between this site and the OpenBSD project exists or is implied.

valid-html401.png