You are not logged in.

#1 2010-07-31 03:29:11

marfig
Member
From: Portugal
Registered: 2010-07-30
Posts: 189
Website

[SOLVED] Can the Linux tty support 256 colors? *

I apologize for asking a Linux specific question. I hope this is still in the context of this forum.

I ran ArchLinux without X. I'm using Arch as a means to learn Linux and for now I'm only interested in the console. As I started dwelling, in colors I bumped into the first problem in these past weeks for which I cannot find a clear answer by searching here, on the wiki, or even on google.

My shell is Bash. Can I use it in 256 color mode or is this only supported by terminals running a shell?
My current framebuffer resolution supports it (1366x768 24bit). But can bash? I cannot seem to enable it. This is what I was trying to do in .bashrc:

function ECOLOR () { echo -ne "\[\033[38;5;$1m\]"; }
export PS1="`ECOLOR 172`\u@\h \W \$\[\033[0m\] "

Moderator edit: topic title clarified

Last edited by marfig (2010-07-31 12:52:24)


I probably made this post longer than it should only because I lack the time to make it shorter.
- Paraphrased from Blaise Pascal

Offline

#2 2010-07-31 03:43:09

Square
Member
Registered: 2008-06-11
Posts: 435

Re: [SOLVED] Can the Linux tty support 256 colors? *

The number of colors available in your command line depends on the terminal, not the shell. Also, I believe the only way to achieve 256-colors in the linux console/tty/vc is to hack the kernel, since it only supports 8 colors reguardless of the resolution/depth.


 

Offline

#3 2010-07-31 04:03:35

marfig
Member
From: Portugal
Registered: 2010-07-30
Posts: 189
Website

Re: [SOLVED] Can the Linux tty support 256 colors? *

I was thinking that the framebuffer console (fbcon) also took over the color resolution of the VT100 terminal emulator in the kernel, as it does for the display resolution.

So bit depth in fb is only to guarantee terminal support?


I probably made this post longer than it should only because I lack the time to make it shorter.
- Paraphrased from Blaise Pascal

Offline

#4 2010-07-31 04:11:45

dunz0r
Member
From: Sweden
Registered: 2009-03-30
Posts: 258
Website

Re: [SOLVED] Can the Linux tty support 256 colors? *

You can poke around in vt.c if you know C. I think that's where the magic takes place.


RTFM or GTFO
hax0r.se

Offline

#5 2010-07-31 04:14:31

Square
Member
Registered: 2008-06-11
Posts: 435

Re: [SOLVED] Can the Linux tty support 256 colors? *

Well, you can use some framebuffer devices to display images and set a background image... but the text colors are still limited by the kernel's definitions.

I may not be saying this entirely correct, so hopefully someone else can come in and fully explain the situation.

Last edited by Square (2010-07-31 04:15:00)


 

Offline

#6 2010-07-31 06:10:11

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: [SOLVED] Can the Linux tty support 256 colors? *

Is your question whether you can get 256 colour support on ttys? Or on terminal emulators, like the ones you use in a WM?

Edit: since you're running without X, it's a tty. I'm changing your topic title.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#7 2010-07-31 07:46:32

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: [SOLVED] Can the Linux tty support 256 colors? *

This is quoted from somewhere in the net:
"Although the Linux frame-buffer supports 256 (or more) colors, the Linux console driver does not; therefore, console applications are still limited to 16 colors on the Linux console, frame-buffer or not."

This is a decades old problem. As far as I know it would be a major task to alter the linux console color capabilities. Thus nobody succeded so far. Unless you find another console which directly works on the framebuffer there will be no 256-colors capability on TTY.


To know or not to know ...
... the questions remain forever.

Offline

#8 2010-07-31 08:22:20

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: [SOLVED] Can the Linux tty support 256 colors? *

bernarcher wrote:

Unless you find another console which directly works on the framebuffer there will be no 256-colors capability on TTY.

And they exist so don't feel dissuaded.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#9 2010-07-31 08:46:44

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: [SOLVED] Can the Linux tty support 256 colors? *

fsckd wrote:
bernarcher wrote:

Unless you find another console which directly works on the framebuffer there will be no 256-colors capability on TTY.

And they exist so don't feel dissuaded.

Quite. I found a few quite some time ago as well. But I lost the references.

Could you provide some pointers?


To know or not to know ...
... the questions remain forever.

Offline

#10 2010-07-31 09:42:02

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: [SOLVED] Can the Linux tty support 256 colors? *

I haven't used any, but sure. *points to Google*


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#11 2010-07-31 12:51:25

marfig
Member
From: Portugal
Registered: 2010-07-30
Posts: 189
Website

Re: [SOLVED] Can the Linux tty support 256 colors? *

Excellent folks. This is more than solved.

Thank you for all the input.

Last edited by marfig (2010-07-31 12:51:52)


I probably made this post longer than it should only because I lack the time to make it shorter.
- Paraphrased from Blaise Pascal

Offline

#12 2011-09-07 10:27:37

TheImmortalPhoenix
Member
From: 127.0.0.1
Registered: 2011-08-13
Posts: 436

Re: [SOLVED] Can the Linux tty support 256 colors? *

Sorry if i write here but how did you resolve marfig? I've installed fbterm but tty stille have 8 colors....

Offline

#13 2011-09-07 13:28:39

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: [SOLVED] Can the Linux tty support 256 colors? *

TheImmortalPhoenix wrote:

Sorry if i write here but how did you resolve marfig? I've installed fbterm but tty stille have 8 colors....

xterm has a 256 color mode extension, FbTerm also add it in this version. But xterm's 256 color escape sequences conflict with the linux sequences implemented by FbTerm, so private escape sequences were introduced to support this feature:

ESC [ 1 ; n }                   set foreground color to n (0 - 255)
ESC [ 2 ; n }                   set background color to n (0 - 255)
ESC [ 3 ; n ; r ; g ; b }       set color n to (r, g, b) ,  n, r, g, b all in (0 - 255)

and a new terminfo database entry named "fbterm" was added to use these private sequences, all program based on terminfo should work with it. By default, FbTerm sets environment variable "TERM" to value "linux", you need run "TERM=fbterm /path/to/program" to enable 256 color mode.

Source: http://code.google.com/p/fbterm/

Offline

#14 2011-09-07 14:53:14

TheImmortalPhoenix
Member
From: 127.0.0.1
Registered: 2011-08-13
Posts: 436

Re: [SOLVED] Can the Linux tty support 256 colors? *

in tty i run TERM=fbterm /usr/bin/fbterm but it remains with 8 colors...

Offline

#15 2011-09-07 15:13:45

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: [SOLVED] Can the Linux tty support 256 colors? *

TheImmortalPhoenix wrote:

in tty i run TERM=fbterm /usr/bin/fbterm but it remains with 8 colors...

Try:

export TERM=fbterm && fbterm

Offline

#16 2011-09-07 16:04:45

TheImmortalPhoenix
Member
From: 127.0.0.1
Registered: 2011-08-13
Posts: 436

Re: [SOLVED] Can the Linux tty support 256 colors? *

Don't change...tput colors: 8

Offline

#17 2011-09-07 18:41:19

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: [SOLVED] Can the Linux tty support 256 colors? *

TheImmortalPhoenix wrote:

Don't change...tput colors: 8

http://code.google.com/p/fbterm/issues/detail?id=29

Have you tried google?

Offline

#18 2011-09-07 19:26:58

TheImmortalPhoenix
Member
From: 127.0.0.1
Registered: 2011-08-13
Posts: 436

Re: [SOLVED] Can the Linux tty support 256 colors? *

Don't work...i'm trying everything....

Offline

#19 2011-09-07 19:40:34

Ashren
Member
From: Denmark
Registered: 2007-06-13
Posts: 1,229
Website

Re: [SOLVED] Can the Linux tty support 256 colors? *

Are you sure you tried this part:

To enable 256 color mode only when fbterm is active, you may execute 'FBTERM=1
fbterm', and add  '[ -n "$FBTERM"] && export TERM=fbterm' to the end of ~/.bashrc
if the shell is bash.

?

This works for me.

tYTh0YQ

Last edited by Ashren (2011-09-07 20:02:48)

Offline

#20 2011-09-07 20:16:44

TheImmortalPhoenix
Member
From: 127.0.0.1
Registered: 2011-08-13
Posts: 436

Re: [SOLVED] Can the Linux tty support 256 colors? *

The output is 256, but color remains to 8 bit....

Offline

#21 2011-09-09 07:12:52

rejoin
Member
Registered: 2011-06-06
Posts: 43

Re: [SOLVED] Can the Linux tty support 256 colors? *

Isn't 8 bit=256?

Offline

Board footer

Powered by FluxBB