Currently viewing entries from 7 April, 2008

Xterm Preferances with no Config File

green screen

green screen,
originally uploaded by matthewpoer.

Some of us geeks like the idea of colored terminals, especially when the resulting terminal matches our ultra-lean desktops (see right). But how can we make an aterm or xterm window launch with these colors without having to define them each time (xterm -fg green -bg black)?

I’ll tell you how! Create a shell script called xterm that contains the
following:

  #!/bin/sh
/usr/bin/xterm -fg green -bg black
exit 0

Run “chmod +x xterm” to make the file executable. Store it in your own ~/bin directory.

Make sure that ~/bin is in the start of your path. Run “echo $PATH”
to see what it contains, it should be something like this:

  matthew@anewt:~$ echo $PATH
/home/matthew/bin:/usr/local/bin:/usr/bin:/bin:/usr/games

If you don’t see /home/USERNAME/bin in your path, add it via your .bash_profile. This line will do it: PATH=~/bin:”${PATH}”

After modifying .bash_profile, the user must log out and back in for changes to take effect.

Now, because you have your own executable named xterm, and it is before the /usr/bin/xterm in your path, your shell will prefer it over the other. So simply running ‘xterm’ runs your own.

However, menu entries and calls from other applications may still specifically call /usr/bin/xterm specifically, in which case you’ll still be given the default system settings. If and when this occurs, you must work with that menu or application to call your own program, either with ‘xterm’ or ‘~/bin/xterm’. Most window managers and desktop environments make this simple enough, so I must let you figure it out yourself.