13

Suppose, I have a system without X server. I can only log in from the console. It seems, by default linux console supports only 8 colors:

# tput colors
8

Is it possible to use 256 colors in the console, same as I would use in a terminal emulator (ie terminator) ?

While googling, Ihave found many similar questions (many of them over 10 years old), but none clear answer. Somebody suggests to use framebuffer, some other people suggest to append TERM argument to kernel boot options.

At the moment, I only pass one extra option as kernel boot parameter:

append="video=1280x720"

I believe passing the video resolution only works in modern kernels with kernel mode setting support, but I am not sure about that.

Is it possible to use 256 colors in modern linux console (tty)

How?

I am using Debian Wheezy with kernel 4.1

UPDATE:

based on suggestion from @muru, I have tried fbterm. While it works with 256 colors, it has very ugly/garbled fonts. Besides, there is a constantly blinking cursor in the lower-left corner, which I find distracting.

Can I use 256 colors in the console without fbterm/framebuffer ?

Where does the 8 color limit in the console come from ?

Martin Vegter
  • 358
  • 75
  • 236
  • 411
  • FbTerm apparently does: http://superuser.com/a/492078/334516, http://askubuntu.com/a/57128/158442 – muru Jan 09 '16 at 10:01
  • @muru - thanks for the suggestion. I have updated my question. – Martin Vegter Jan 09 '16 at 11:27
  • Of course, if you set TERM to xterm-256color for the Linux console, you'll simply open up another can of worms. This link gives a hint. – Thomas Dickey Jan 09 '16 at 13:06
  • RE: UPDATE I dont have the "ugly/garbled" font, probably because I use a different font. It could be wrong $TERM (has to be fbterm before you start fbterm) or not 32bit video mode or both. Turn off the console cursor before starting fbterm, and turn it on once you are there, using tput. https://unix.stackexchange.com/questions/220330/hide-and-unhide-cursor-with-tput – Paul Wratt Mar 28 '20 at 14:47
  • BTW I also looked at the fbterm source, and it would be simple (but time consuming) to convert the escape code sequences to use xterm-256color instead (fbterm-xterm). The $TERM would also need to be inlined with terminfo and termcap naming conventions (fbterm-xterm-256color or fbterm-256color) to "slot" into existing shell scripts. Note that fbterm uses TERM=fbterm as a switch to turn on the 256 color option, otherwise its 16 colors (or maybe the same as the underlying). – Paul Wratt Mar 28 '20 at 15:11

1 Answers1

4

The actual question consists of these two items:

  • Can I use 256 colors in the console without fbterm/framebuffer ?

  • Where does the 8 color limit in the console come from ?

To the first: apparently not. All of the suggested approaches use fbterm. To the second: it comes from the terminal description (aka "terminfo entry"). For Linux console, with TERM set to linux, that says the terminal supports 8 colors. tput gets its information from the terminal database.

One of the items in the thread quoted says that fbterm uses different escape sequences for setting colors than xterm. If that is the case (and given the propensity of Emacs users to hardcode things), there's no suitable terminal entry for fbterm.

Thomas Dickey
  • 76,765
  • The Linux kernel terminal emulator has gained some additional SGR support in recent years: https://github.com/torvalds/linux/commit/cec5b2a97a11ade56a701e83044d0a2a984c67b4 https://github.com/torvalds/linux/commit/cc67dc28b33917227214a692534d817d727fb934 https://github.com/torvalds/linux/commit/fadb4244085cd04fd9c8b3a4b3bc161f506431f3 – JdeBP May 30 '18 at 13:32
  • 2
    sure - you might not have read the checkin comment: Because of hardware limitations of VGA consoles, colours are downgraded* to 16 foregrounds and 8 backgrounds. On fbdev consoles it would be possible to support them without quality loss, but adding that would require quite a large amount of code.* – Thomas Dickey May 30 '18 at 17:53
  • I already read the comment, long since, which is why I wrote that it had gained some additional SGR support. (-: But notice that it's thus not always an 8 colour limit as you wrote in 2016 here. – JdeBP May 30 '18 at 23:12
  • It's still the same palette of 8 ANSI and 8 bold/bright ANSI as has been for 25+ years (and ncurses has had a linux-16color entry since 2009). – Thomas Dickey May 30 '18 at 23:34
  • I have previously looked into the kernel source (about the time of the OP), and deemed it a simple process to allow 256 color (linux-256color). That patch would never be accepted upstream for the same reason as Thomas Dickey comment above, "Because of hardware limitations". IE Linux must work on the lowest common denominator. – Paul Wratt Mar 28 '20 at 14:58
  • Has anyone made this patch? Even if it never gets accepted upstream, it would be a nice treat for people who have newer machines and want to compile the kernel themselves. – Not me Jun 30 '20 at 02:13