Suggestion: Give CRT a way for programs to differentiate it from more "standard" looking terminals. #485

Open
opened 2018-11-24 22:55:12 +01:00 by LunarLambda · 6 comments
LunarLambda commented 2018-11-24 22:55:12 +01:00 (Migrated from github.com)

One way would be to have /usr/share/terminfo/c/cool-retro-term be a link to /usr/share/terminfo/x/xterm, and set TERM to cool-retro-term, or to keep TERM as-is and export a different variable, like COOL_RETRO_TERM, containing a version number or something else.

The reason for this is that there is no easy way for programs (like Vim) to determine what terminal I'm running in beyond checking $TERM. Since CRT is visually quite different from pretty much any other terminal emulator out there, it would be nice to be have a little if statement in my setups to pick different visual styling for it. Since, for example, using solarized light in vim might look fine in a standard xterm, but would probably not work at all in CRT, since it's a very bright colorscheme.

One way would be to have /usr/share/terminfo/c/cool-retro-term be a link to /usr/share/terminfo/x/xterm, and set TERM to cool-retro-term, or to keep TERM as-is and export a different variable, like COOL_RETRO_TERM, containing a version number or something else. The reason for this is that there is no easy way for programs (like Vim) to determine what terminal I'm running in beyond checking $TERM. Since CRT is visually quite different from pretty much any other terminal emulator out there, it would be nice to be have a little if statement in my setups to pick different visual styling for it. Since, for example, using solarized light in vim might look fine in a standard xterm, but would probably not work at all in CRT, since it's a very bright colorscheme.
SilverWolf32 commented 2019-03-30 02:02:50 +01:00 (Migrated from github.com)

There's actually a $TERM_PROGRAM environment variable designed for just this sort of thing, and it seems to be becoming a sort-of-standard! Apple's built-in Terminal.app sets it to "Apple_Terminal", while iTerm 2 sets it to "iTerm.app". GNOME Terminal sets it to "gnome-terminal". CRT currently leaves it blank. There's even a $TERM_PROGRAM_VERSION too, if you really want to get specific!

There's actually a $TERM_PROGRAM environment variable designed for just this sort of thing, and it seems to be becoming a sort-of-standard! Apple's built-in Terminal.app sets it to "Apple_Terminal", while iTerm 2 sets it to "iTerm.app". GNOME Terminal sets it to "gnome-terminal". CRT currently leaves it blank. There's even a $TERM_PROGRAM_VERSION too, if you really want to get specific!
SilverWolf32 commented 2019-04-02 16:28:00 +02:00 (Migrated from github.com)

Currently as an interim stopgap measure I'm detecting it as $TERM="xterm", since every other terminal I use happens to have 256 color support and sets it to "xterm-256color", but that may not work for you. And of course it might mess you up if you want to log into Linux VT consoles.

Currently as an interim stopgap measure I'm detecting it as $TERM="xterm", since every other terminal I use happens to have 256 color support and sets it to "xterm-256color", but that may not work for you. And of course it might mess you up if you want to log into Linux VT consoles.
jwbrase commented 2019-05-22 05:56:15 +02:00 (Migrated from github.com)

One thing you could do is set TERM to vt100. That suppresses color in vim, though, oddly, not for "ls --color=auto".

One thing you could do is set TERM to vt100. That suppresses color in vim, though, oddly, not for "ls --color=auto".
SilverWolf32 commented 2019-05-22 15:02:55 +02:00 (Migrated from github.com)

Wouldn't that mess up keys and escape sequences as well, though?

Wouldn't that mess up keys and escape sequences as well, though?
jphebus commented 2019-08-11 22:33:15 +02:00 (Migrated from github.com)

The standard seems to be for a terminal emulator that supports 256 colors to append -256color to its TERM identification string, like xterm-256color or rxvt-unicode-256color. So, I would recommend identifying as cool-retro-term-256color. However, Cool Retro Term would need its own terminfo entry under /etc/terminfo or /lib/terminfo to describe its capabilities. This would be the correct long-term solution, I think.

As a short-term fix, so that Bash, Vim, Mutt, etc. would realize that Cool Retro Term supports 256 colors, I added the following to my .bashrc file (near the beginning):

# Cool Retro Term doesn't properly identify as a 256 color terminal.
# Force it to identify as xterm-256color instead of just xterm.
[ -z "$COLORSCHEMES_DIR" ] || export TERM='xterm-256color'

This works because Cool Retro Term sets a COLORSCHEMES_DIR environment variable that can be detected. But, this is a pretty clunky workaround.

The standard seems to be for a terminal emulator that supports 256 colors to append -256color to its TERM identification string, like xterm-256color or rxvt-unicode-256color. So, I would recommend identifying as cool-retro-term-256color. However, Cool Retro Term would need its own terminfo entry under /etc/terminfo or /lib/terminfo to describe its capabilities. This would be the correct long-term solution, I think. As a short-term fix, so that Bash, Vim, Mutt, etc. would realize that Cool Retro Term supports 256 colors, I added the following to my .bashrc file (near the beginning): ``` # Cool Retro Term doesn't properly identify as a 256 color terminal. # Force it to identify as xterm-256color instead of just xterm. [ -z "$COLORSCHEMES_DIR" ] || export TERM='xterm-256color' ``` This works because Cool Retro Term sets a COLORSCHEMES_DIR environment variable that can be detected. But, this is a pretty clunky workaround.
SilverWolf32 commented 2019-08-11 22:47:44 +02:00 (Migrated from github.com)

CRT doesn't just support 256 colors (as identified by xterm-256color). It also supports full-on 24-bit color! (e.g. #rrggbb)

Terminal-wise – keys and such – it's an xterm as far as I know, so we shouldn't need to do anything with $TERM beyond setting it to xterm-256color. But having a $TERM_PROGRAM set would be nice, so we can have a different theme for bright glowy CRT (as mentioned in the OP).

There's also apparently a $COLORTERM variable, which gnome-terminal sets to truecolor, and iTerm 2 sets to something (I can't remember exactly what). That would be good for 24-bit color detection.

CRT doesn't just support 256 colors (as identified by xterm-256color). It also supports _full-on 24-bit color!_ (e.g. #rrggbb) Terminal-wise – keys and such – it's an xterm as far as I know, so we shouldn't need to do anything with $TERM beyond setting it to `xterm-256color`. But having a $TERM_PROGRAM set would be nice, so we can have a different theme for bright glowy CRT (as mentioned in the OP). There's also apparently a $COLORTERM variable, which gnome-terminal sets to `truecolor`, and iTerm 2 sets to _something_ (I can't remember exactly what). That would be good for 24-bit color detection.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: seeseemelk/cool-retro-term#485
No description provided.