Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the TERM_PROGRAM environment variable #1837

Closed
DRSDavidSoft opened this issue Feb 26, 2019 · 6 comments
Closed

Set the TERM_PROGRAM environment variable #1837

DRSDavidSoft opened this issue Feb 26, 2019 · 6 comments

Comments

@DRSDavidSoft
Copy link

Description Feature Request

On Linux and macOS, the TERM_PROGRAM variable is set to the terminal name (e.g. Hyper, Apple_Terminal, etc).

Would it be possible (and appropriate) for ConEmu to follow the convention and set %TERM_PROGRAM% to something like ConEmu?

Purpose

  • This can be used to identify the Terminal via running shell scripts.
@TeamSpen210
Copy link

This isn't as necessary, since ConEmu already sets quite a number of unique environment variables to expose various configuration. You could simply check for the presence of those, or try executing ConEmuC /IsConEmu to make sure.

Following conventions is good though to prevent special-casing.

@Maximus5
Copy link
Owner

On Linux and macOS, the TERM_PROGRAM variable is set to the terminal name

That is not true. I've checked three terminals on Ubuntu, and only one defines this variable. And it's vscode :)

@Maximus5
Copy link
Owner

I'm not against the unification, but does it make sense?
Quick googling shows same proposals were rejected: mintty/mintty#776, alacritty/alacritty#781

BTW, many terminals set VTE_VERSION variable.

@Maximus5
Copy link
Owner

And COLORTERM

@Maximus5 Maximus5 added this to To Do in Inspection via automation Mar 3, 2019
@Maximus5
Copy link
Owner

Maximus5 commented Mar 3, 2019

I'm in doubt, really...
On the one hand unification is good, but on the other hand neither terminal I've checked in Ubuntu sets this variable.
We may not count vscode (it's not a real terminal and it's a cross-platform application).

I decides not to spawn more environment than we have already.

But! You may add set TERM_PROGRAM=conemu in the Environment and it will answer you case.

@Maximus5 Maximus5 closed this as completed Mar 3, 2019
Inspection automation moved this from To Do to Done Mar 3, 2019
@DRSDavidSoft
Copy link
Author

DRSDavidSoft commented Mar 4, 2019

@Maximus5 You're right. As you said, the support for this variable seems to be limited mainly to macOS and cross platform terminals (e.g. Hyper).

Terminals in support of TERM_PROGRAM

name value request 2
macOS Terminal Apple_Terminal
iTerm2 iTerm.app
Hyper 3 Hyper (formerly HyperTerm) link
Terminus 3 Terminus link
FluentTerminal 3 FluentTerminal link
VS Code's integrated terminal vscode link

1 Until recently, Terminus set the variable Terminus=1 instead of TERM_PROGRAM=Terminus (Eugeny/tabby#702)
2 Most of the terminals above did not implement the TERM_PROGRAM variable until someone asked (the request column)
3 Furthermore, FluentTerminal sets TERM=xterm variable. Hyper and Terminus sets TERM=xterm-256color.

Respectively, the macOS terminal has always used TERM_PROGRAM=Apple_Terminal in their implementation.

Benefits

Terminals that do not provide TERM_PROGRAM

Rejections

Not-implemented

Unknown/Un-tested

  • Terminator – The GNOME's terminal emulator (Ubuntu, CentOS Linux and FreeBSD)
  • Terminology – Another terminal emulator for Linux and BSD
  • Termite – A terminal emulator for GTK+ (Linux, *NIX)

Programs that check TERM_PROGRAM

  • Yarn: uses TERM_PROGRAM to display emojis on Hyper and macOS terminals. (impl)
  • neofetch: uses TERM_PROGRAM to identify the terminal emulator program (impl)
  • neovim: uses TERM_PROGRAM to to address terminal emulator capabilities and bugs (impl)
  • …and more

TL;DR: This is mainly a macOS-centric variable, and seldom terminals outside macOS set it; often if the program is cross-platform and/or a user has asked for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Inspection
  
Done
Development

No branches or pull requests

3 participants