5

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...

2
  • Beware of using ls to test this - the ls colors will still output until you unalias ls, and unset LS_COLORS. Jan 16, 2015 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... Jan 16, 2015 at 16:37

1 Answer 1

3

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .