is it possible to have application-specific xterm settings?

I know how to write an .Xresources file to modify the appearance of xterm. However, I wonder if it is possible to have application specific .Xresources, such that I can use the light solarized theme for when I use mutt (xterm -e mutt), a dark solarized theme for (say) use of the terminal for command line activity, and a third theme for perhaps other things. Sorry if this is a trivial question, but at least I could not find the answer.

Asked By: user3236841

||

You could of course have a script that just sets all the correct resources settings via the -xrm resourcestring and opens these programs.

Two observations:

  • as far as I know, xterm doesn’t support specifying a separate configuration file that would make switching "color profiles" easier. Other terminal emulators do.
  • most modern terminals support more than 256 colors, so that the programs run in the terminal can decide on the actual color they display themselves, rather than you having to set up a palette awkwardly. So, not using xterm but a somewhat modern terminal emulator might already solve the issue to begin with.

long story short:

  • either use `xterm -xrm ‘very long string containing your resources settings’ -e mutt’ to start mutt with a different configuration, or
  • or, and this is what I’d recommend, maybe don’t base your daily workflow on a graphical program that predates graphics cards with more than 16384 colors. xterm is nice for historical reasons, and I have the biggest respect for Thomas Dickey that after nearly 40 years, he’s still keeping xterm runnable.
    But: You want solid unicode support when you converse with people using email (so, at least, uxterm, but really something that wasn’t architected before people invented unicode might be a good idea); you want actual color support.

For the reasons above, I’d recommend trying a terminal that is maybe a bit slimmer in terms of historic baggage and a bit faster on modern hardware and a bit more versatile in modern features. If you don’t like graphical configuration dialogs too much, but would rather work in a simple text configuration file, I think alacritty should work for you quite nicely. I know it works on Linux, FreeBSD, OpenBSD, Darwin/Mac OS, there’s netbsd packages. So, probably, there’s a trivial way to try it on your platform of choice. Maybe do that, and see whether 15 minutes with the example configuration do what you want. You can run alacritty --config-file yourconfig.yml -e mutt for example, if you want a separate configuration just for running mutt. (There’s also a program, alacritty-msg, which can be used to change configuration settings like alacritty-msg config font.size=22 on the fly from within scripts, but it’s usually not shipped, so I won’t advertise it here.)

Answered By: Marcus Müller
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.