diff --git a/src/Command/Environment/EnvironmentSshCommand.php b/src/Command/Environment/EnvironmentSshCommand.php index cfe5b6d27b..f139a106d8 100644 --- a/src/Command/Environment/EnvironmentSshCommand.php +++ b/src/Command/Environment/EnvironmentSshCommand.php @@ -90,9 +90,19 @@ protected function execute(InputInterface $input, OutputInterface $output) throw new InvalidArgumentException('The cmd argument is required when running via "multi"'); } + $options = $input->getOption('option'); + + // Send the TERM environment variable by default, when it has a + // supported value and when opening a shell (i.e. when no command is + // specified). + $validTermInfo = ['xterm', 'xterm-color', 'xterm-256color']; + if (empty($remoteCommand) && in_array(getenv('TERM'), $validTermInfo, true)) { + $options = array_merge(['SendEnv TERM'], $options); + } + /** @var \Platformsh\Cli\Service\Ssh $ssh */ $ssh = $this->getService('ssh'); - $command = $ssh->getSshCommand($sshUrl, $input->getOption('option'), $remoteCommand); + $command = $ssh->getSshCommand($sshUrl, $options, $remoteCommand); /** @var \Platformsh\Cli\Service\Shell $shell */ $shell = $this->getService('shell'); diff --git a/src/Service/Ssh.php b/src/Service/Ssh.php index ffe21cf3be..84edf78329 100644 --- a/src/Service/Ssh.php +++ b/src/Service/Ssh.php @@ -99,8 +99,6 @@ private function getSshOptions($hostIsInternal) { $options = []; - $options[] = 'SendEnv TERM'; - if ($this->output->isDebug()) { if ($this->config->get('api.debug')) { $options[] = 'LogLevel DEBUG3';