May 27, 2016

A Better xterm

A Better xterm

Well, if you are like me, and use xterms to get things done, and have them spread around your display - maybe, you have gotten tired of looking at these drab default xterms?

Blank Xterm

xterms are lightweight and often the only thing works without latency-frustration when working over VNCs (located on another continent…). Consider using FluxBox as your window manager, if you find yourself in such a situation (it has a neat feature to clip and tab all the windows you have open - including your xterms).

Over, the year, like many others, I have ended up gathering some settings to determine how my xterm looks. Here’s my .Xresources (make one in your home dir ~/, if you don’t already have one).

!right hand side scrollbar...
xterm*rightScrollBar: true
xterm*ScrollBar: true

! stop output to terminal from jumping down to bottom of scroll again
! xterm*scrollTtyOutput: false

XTerm*faceName: Bitstream Vera Serif Mono
xterm*faceSize: 11
! xterm*vt100*geometry: 80x60
xterm*saveLines: 16384
xterm*loginShell: true
xterm*charClass: 33:48,35:48,37:48,43:48,45-47:48,64:48,95:48,126:48
xterm*termName: xterm-color
xterm*eightBitInput: false

!BLK Cursor
#define _color0        #000d18
#define _color8        #000d18
!RED Tag
#define _color1        #e89393
#define _color9        #e89393
!GRN SpecialKey
#define _color2        #9ece9e
#define _color10       #9ece9e
!YEL Keyword
#define _color3        #f0dfaf
#define _color11       #f0dfaf
!BLU Number
#define _color4        #8cd0d3
#define _color12       #8cd0d3
!MAG Precondit
#define _color5        #c0bed1
#define _color13       #c0bed1
!CYN Float
#define _color6        #dfaf8f
#define _color14       #dfaf8f
!WHT Search
#define _color7        #efefef
#define _color15       #efefef
!FMT Include, StatusLine, ErrorMsg
#define _colorBD       #ffcfaf
#define _colorUL       #ccdc90
#define _colorIT       #80d4aa
!TXT Normal, Normal, Cursor
#define _foreground    #dcdccc
#define _background    #1f1f1f
#define _cursorColor   #8faf9f
URxvt*color0         : _color0
URxvt*color1         : _color1
URxvt*color2         : _color2
URxvt*color3         : _color3
URxvt*color4         : _color4
URxvt*color5         : _color5
URxvt*color6         : _color6
URxvt*color7         : _color7
URxvt*color8         : _color8
URxvt*color9         : _color9
URxvt*color10        : _color10
URxvt*color11        : _color11
URxvt*color12        : _color12
URxvt*color13        : _color13
URxvt*color14        : _color14
URxvt*color15        : _color15
URxvt*colorBD        : _colorBD
URxvt*colorIT        : _colorIT
URxvt*colorUL        : _colorUL
URxvt*foreground     : _foreground
URxvt*background     : _background
URxvt*cursorColor    : _cursorColor
XTerm*color0         : _color0
XTerm*color1         : _color1
XTerm*color2         : _color2
XTerm*color3         : _color3
XTerm*color4         : _color4
XTerm*color5         : _color5
XTerm*color6         : _color6
XTerm*color7         : _color7
XTerm*color8         : _color8
XTerm*color9         : _color9
XTerm*color10        : _color10
XTerm*color11        : _color11
XTerm*color12        : _color12
XTerm*color13        : _color13
XTerm*color14        : _color14
XTerm*color15        : _color15
XTerm*colorBD        : _colorBD
XTerm*colorIT        : _colorIT
XTerm*colorUL        : _colorUL
XTerm*foreground     : _foreground
XTerm*background     : _background
XTerm*cursorColor    : _cursorColor

And then source that one-time with xrdb -merge .Xresources. Open up a new xterm, and it should look like this:

better xterm

This a good default xterm to have with a dark background and light foreground with a better reading font. This is usually good enough. But having a lot of these around, can get confusing at times. So, I decided to colorize them! Random dark BG with a light FG (or other way around if that’s your thing). First, write this script down somewhere (say, ~/bin/


# Foreground 
# Higher value = lighter color
n1=$(( 256 - $n ))
fg=$( printf "#%x%x%x\n" $(( $RANDOM % $n1 + $n )) \
                                $(( $RANDOM % $n1 + $n )) \
                                $(( $RANDOM % $n1 + $n )) )

# Background 
# Low value = darker color
bg=$( printf "#%x%x%x\n" $(( $RANDOM % $m + 16 )) \
                                $(( $RANDOM % $m + 16 )) \
                                $(( $RANDOM % $m + 16 )) )

# summon xterm
# xterm -fn fixed -fg "$fg" -bg Gray12 &
xterm -fn fixed -fg "$fg" -bg "$bg" &

If you call this, you get nice and pretty terminals. Alias that script in your .baschrc or .cshrc to some command you can call easily, say term

alias term "~/bin/"

enter image description here

Edit: Part-II: A Much Better xterm

No comments:

Post a Comment

You got something to say? Wait! I need to get my microphone array online.