4

I would like to disable colours in my xterm at runtime. Reason being that some programs lack the sanity to use them in proper way.

For example:

$ sane-program
color output

$ disable-color
$ less-sane-program
black-white output

$ enable-color
$ sane-program
color output

I know I can use xterm -cm, or change colorMode in my ~/.Xdefaults, but that requires starting new xterm. I tried setting TERM to xterm-old or an invalid string (arggggh), but I still have colours. xtermcontrol also doesn't have an option.

Ctrl+right click and deselecting "Allow color ops" doesn't seem to do anything either (it would be cool if this worked).

Filtering out the colour codes with sed is the workaround I use now, but this doesn't work for interactive programs...

  • Beware of using ls to test this - the ls colors will still output until you unalias ls, and unset LS_COLORS. – Danny Staple Jan 16 '15 at 13:53
  • 1
    @DannyStaple How is ls different than $anything_else? ls outputs ANSI color codes, and I want xterm to ignore this ... Or am I missing something? If I start xterm -cm, ls is without colours... – Martin Tournoij Jan 16 '15 at 16:37
1

Short: if you don't want to start a new xterm, you cannot suppress colors.

Long:

  • while you could change TERM to a description which doesn't use color (such as xterm-old), some applications do not use the terminal database. For instance, GNU ls uses its own program, which insists that vt100's are color terminals. Other programs may simply hardcode their behavior.
  • the Allow Color Ops menu entry is the allowColorOps resource:
       allowColorOps (class AllowColorOps)
               Specifies  whether control sequences that set/query the dynamic
               colors should be allowed.  ANSI colors are unaffected  by  this
               resource setting.  The default is "true".

For a discussion of dynamic colors, see XTerm Control Sequences.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.