Couldn't we enable 256 colors by default on TERM?

Pádraig Brady P at draigBrady.com
Thu May 31 11:42:59 UTC 2012


On 05/31/2012 11:09 AM, Marc Deop i Argemí wrote:
> On Thursday 31 May 2012 02:20:26 Pádraig Brady wrote:
>> On 05/30/2012 04:16 PM, Marc Deop wrote:
>>> On Wednesday 30 May 2012 10:04:49 Pádraig Brady wrote:
>>>> I've some notes about 256 colors here:
>>>> http://www.pixelbeat.org/docs/terminal_colours/#256
>>>>
>>>
>>> That information is mostly fine. There are some errors though (you say you set your TERM variable in your .bashrc...)
>>
>> Yes. If you follow the link to my .bashrc it further clarifies that
>> to handle all cases, the variable should be set earlier in ~/.profile
>> or system wide in /etc/profile.d/...
>>
> 
> Still wrong in my opinion. This should be set by your terminal emulator (be it konsole, gnome-terminal or whatever) and not in your personal environment. You would end up having to check for *a lot* of things

I'm leaning towards needing the configurability of a /etc/profile.d/256color.sh file.
That could be a central config point and support various required TERM and TERMCAP tweaks.

>>>> If you restrict yourself to local xterms
>>>> (of most varieties) you're fine.
>>>>
>>>
>>> Nowadays you'll be fine almost everywhere. Your system should not set the TERM variable to "xterm" or whatever if you are in a virtual terminal (that would happen if you set your TERM variable in your .bashrc for example...)
>>
>> Well that also happens if set in /etc/profile etc.
>> What you need to do I think is guard like:
>>
>> $ cat /etc/profile.d/256color.sh
>> [ "$TERM" = 'xterm' ] && TERM=xterm-256color; export TERM
> 
> What happens with "urxvt" or "eterm" terminals?
> 
> As said above, .profile or .bashrc or whatever is not a good place to set this things
> 
>>
>>>
>>>> However...
>>>>
>>>> 256 color doesn't work correctly on Linux virtual consoles.
>>>>
>>>
>>> Totally true
>>
>> Handled with the conditional above
> 
> That works for VT that use xterm as TERM environment but... what of other ones?

So why do they have separate TERM than 'xterm';
do they have separate facilities they want to distinguish?
I tried urxvt there and it sets TERM=rxvt-unicode
I notice that vim at least recognizes this as 256 color already.

Note 'rxvt-unicode' has the same issue when I ssh to solaris:

$ man ls
WARNING: terminal is not fully functional
/tmp/blahblah (press RETURN)

If the minority of xterms want to set their own TERM value,
then we shouldn't worry about it I think, as those values
will have to be dealt specifically by apps/systems anyway.

By mapping xterm to xterm-256color we catch most terminals,
and hopefully there are none of those that don't support 256 colors.
Any that don't could be excluded anyway.

>>>> Also since your $TERM is propagated to remote systems
>>>> when you ssh, if they don't support that you'll have issues.
>>>> For example sshing to debian systems (I've not tried newer releases)
>>>> will be problematic unless a package in installed there.
>>>> Also if I ssh to solaris then I need to reset TERM to "xterm"
>>>> for man pages to work correctly etc.
>>>
>>> IMHO this should be the other way around: for old systems where the 256 don't work you should manually set your TERM variable to something that would work and not the other way around
>>
>> This could be contentious.
>>
>> However I notice (from searching the web) is that Mac OS X
>> Terminal's default $TERM value is xterm-256color since Lion 10.7.
>>
>> What I'd do (I will do if you prefer) is to propose the feature at:
>> https://fedoraproject.org/wiki/Releases/18/FeatureList
>> That will both provide a todo list and allow voting on acceptance.
>>
> 
> That sounds reasonable, +1 for me here! :)

I'll let Kévin do this as it was his initiative.
I'll help out wherever is needed.

>> Also in the release notes we should have notes for workarounds
>> for older systems where you would have issues.
>> I notice ncurses-term is still 'standard' rather than 'required' in debian.
>> Perhaps we could log a request for that to change?
>> Note that package is 6.6MB installed so maybe the 256 color support
>> could be merged back to ncurses-base ?
>>
>> I just tried ubuntu 12.04 there and it also doesn't install ncurses-term.
>> I did the following to double check:
>>   $ TERM=xterm-256colors man ls
>>   WARNING: terminal is not fully functional
>>
> 
> You made a spelling mistake there, try again without the "s": xterm-256color

Oops you're right.
In fact ubuntu 12.04 at least does have 256 color support by default.
I.E. not enabled by default, but supported if set:

$ TERM=xterm-256color tput colors
256

>> There is still further issues to consider locally.
>> screen and vim settings would need to be tweaked also as per:
>> http://www.robmeerman.co.uk/unix/256colours
> 
> Vim would work just not with all the colors. We could set an environment configuration enabling 256 colors by default as well, couldn't we?

vim is fine outside of screen.
But when used with screen there needs to be tweaks.
Perhaps Kévin's suggestion of mapping TERM=screen to screen-256color would just work?

> As for screen... I don't even remember how to set it, I would need to do some research  on it
> 
> 
> Great discussion Pádraig :)

cheers,
Pádraig.


More information about the devel mailing list