Terminal: Fix TERM env variable

Some (Fedora) OS/Distros set a default value for TERM such as "dumb", which then breaks
command line tools such as "clear" which try to figure out what terminal they are
running in. Therefore we have to force-set our own TERM value.

Fixes: QTCREATORBUG-30737
Change-Id: I50ac86f17c92dc7bc477cc59ed43ec22025593fb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Marcus Tillmanns
2024-04-30 08:33:48 +02:00
parent 84f0f6ba8b
commit 8b682ac7f5

View File

@@ -119,8 +119,12 @@ void TerminalWidget::setupPty()
Environment env = m_openParameters.environment.value_or(Environment{}) Environment env = m_openParameters.environment.value_or(Environment{})
.appliedToEnvironment(shellCommand.executable().deviceEnvironment()); .appliedToEnvironment(shellCommand.executable().deviceEnvironment());
// Some OS/Distros set a default value for TERM such as "dumb", which then breaks
// command line tools such as "clear" which try to figure out what terminal they are
// running in. Therefore we have to force-set our own TERM value here.
env.set("TERM", "xterm-256color");
// Set some useful defaults // Set some useful defaults
env.setFallback("TERM", "xterm-256color");
env.setFallback("TERM_PROGRAM", QCoreApplication::applicationName()); env.setFallback("TERM_PROGRAM", QCoreApplication::applicationName());
env.setFallback("COLORTERM", "truecolor"); env.setFallback("COLORTERM", "truecolor");
env.setFallback("COMMAND_MODE", "unix2003"); env.setFallback("COMMAND_MODE", "unix2003");