0

I've set the terminal type to monochrome one in inittab file like so:

c2:... tty2 linux-m

but when I type a command with colored output like:

ls --color=always -l

I still get colored result. How can it be if the terminal is set to non-color (tty definition in inittab file like above).

  • Why are you actually trying to setup a purely monochrome terminal in the first place? – Seth Feb 2 '18 at 11:37
0

The terminal type only describes a particular way to use a terminal. There are no guarantees that a terminal actually behaves that way, nor is there any guarantee that a program uses other information for manipulating the terminal.

In this case, the ls program uses its own hard-coded database, which says that "linux" does color.

Further reading: ncurses FAQ Applications miscited as library users

  • Sorry but i can't clearly understand. If the terminal emulator defined by tty2 entry does not support colors how can it disply them when doing 'ls'? – Ringger81 Jan 31 '18 at 17:59
  • As I said: ls does not pay attention to the terminal description, and the terminal can do this whether you use the terminal description or not :-) – Thomas Dickey Jan 31 '18 at 22:29
  • Do what? color 'ls' output?. How can the terminal handles colors if it have been set to 'linux-m' that's monochrome? – Ringger81 Feb 1 '18 at 9:48
  • Can You answer my last question? – Ringger81 Feb 2 '18 at 10:44
  • I already did: in my comment above your question :-) – Thomas Dickey Feb 2 '18 at 21:02
0

As mentioned before those programs are likely directly outputting ANSI escape sequences:

As 256-color lookup tables became common on graphic cards, escape sequences were added to select from a pre-defined set of 256 colors:[citation needed]

ESC[ … 38;5;<n> … m Select foreground color
 ESC[ … 48;5;<n> … m Select background color
 0-  7:  standard colors (as in ESC [ 30–37 m)
 8- 15:  high intensity colors (as in ESC [ 90–97 m)
16-231:  6 × 6 × 6 cube (216 colors): 16 + 36 × r + 6 × g + b (0 ≤ r, g, b ≤ 5)

232-255: grayscale from black to white in 24 steps

This argument would also be strengethend by answers for a similar question titled Disable colours on terminal and SSH on the Unix SE.

In your previous questions for this topic you mentioned you're using xterm. The xterm man page also lists a -cm option to disable recognition of ANSI escape sequences. This is also mentioned in the answers to the linked question:

-cm

This option disables recognition of ANSI color-change escape sequences. It sets the colorMode resource to "false".

What you're doing by setting the terminal information is that you define the capabilities of the terminal (as per man terminfo). As such, what you're doing equates to telling ls and so on that you're sure you can do certain things but that doesn't mean they have to honor it in any way.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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