Celeb Glow
general | March 26, 2026

How do I maintain custom settings of XTerm across sessions?

Is there any way to keep the settings of XTerm that I've applied so that it opens with these settings when I reopen it (e.g. text size, set by Ctrl+RightClick)?

3 Answers

You can either launch xterm with the relevant option (see man xterm) or create an ~/.Xresource file with the setting there. Try running this command:

echo "xterm*font: *-fixed-*-*-*-12-*" >> ~/.Xresources

That will append xterm*font: *-fixed-*-*-*-12-* to your ~/.Xresources file (creating it if it doesn't exist), which is read by xterm when it starts. If you now log out and log in again, (or just run xrdb -merge .Xresources) your xterm will have its font size set to 12. For the various other options you might want to set, see man xterm and add them to the ~/.Xresources file.


NOTE: This works as expected on my Debian and I used this approach for many years and on many distributions to set the various settings for xterm (and aterm which you might want to check out by the way). For some reason, I can't get it to work on my Ubuntu virtual machine but I am hoping that this is specific to my setup. I'd be very surprised if it doesn't work on Ubuntu.

3

Update

It is worth noting that you should, if unsure of what the settings are supposed to look like, to do this:

xrdb -query

which can give a listing like this (MANY lines not included):

...
xterm*background: black
xterm*foreground: #808080
xterm.SimpleMenu*background: #6a6a6a <---- these were
xterm.SimpleMenu*foreground: #bfbfbf <---- the "correct" entries!
xterm.background: black
xterm.bg: black
xterm.fg: white
xterm.foreground: white
...

Now in my particular situation, I was setting things up to have white text on black background. I even used other 'tutorials' and guides. It seems that the resource names can vary slightly from distribution to distribution as you see above.

Your correct entries may not be the same as mine, so if you are having trouble, query the database and look for the entry that describes your current color or just play with each entry till you find the right one, hopefully there will only be a small bit if you havent tried anything yet.

Be warned: some window/display/desktop managers like to copy their current 'color scheme' into the database by force. This can be a pain in the neck. It also means you would have to try to find the script responsible, and disable it.

For me, I was running KDE, so my script was:

/usr/share/kde4/apps/kdisplay/app-defaults/XTerm.ad

But it could be other places depending on the manager you use, and the version of it as well as the distro it is installed on (headache isn't it?). Best thing to do is look for the app-defaults because that seems to be the 'going name' right now. Also, you will know when you hit pay dirt because the file will have something like this:

 xterm*background: WINDOW_BACKGROUND xterm*foreground: WINDOW_FOREGROUND

..which is obviously what you want to get rid of, i believe you can just comment them out with '!' or even move the file to be safe if there is no other content in it.

Hope that helps (others too)

In recent ubuntus the font size and other options can be configured in file /etc/X11/app-defaults/XTerm . I tried files ~/.Xresources and ~/.Xdefaults but that didn't work for me for some reason.

The format is a bit odd, a decent example can seen on this wiki page or just google for "xterm font size xresources"

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy