Skip to content

Commit 1b0c3db

Browse files
committed
Add COLORTERM to the lima shell environment
If the variable is set on the host, forward it. Typical value if set would be COLORTERM=truecolor Signed-off-by: Anders F Björklund <[email protected]>
1 parent 67e465e commit 1b0c3db

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cmd/limactl/shell.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ func shellAction(cmd *cobra.Command, args []string) error {
127127
// required for showing the shell prompt: https://stackoverflow.com/a/626574
128128
sshArgs = append(sshArgs, "-t")
129129
}
130+
if _, present := os.LookupEnv("COLORTERM"); present {
131+
// SendEnv config is cumulative, with already existing options in ssh_config
132+
sshArgs = append(sshArgs, "-o", "SendEnv=\"COLORTERM\"")
133+
}
130134
sshArgs = append(sshArgs, []string{
131135
"-q",
132136
"-p", strconv.Itoa(inst.SSHLocalPort),
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
set -eux
3+
4+
! grep -q "COLORTERM" /etc/ssh/sshd_config || exit 0
5+
6+
# accept any incoming COLORTERM environment variable
7+
sed -i 's/^AcceptEnv LANG LC_\*$/AcceptEnv COLORTERM LANG LC_*/' /etc/ssh/sshd_config
8+
! test -f /sbin/openrc-init || rc-service --ifstarted sshd reload
9+
! command -v systemctl >/dev/null 2>&1 || systemctl reload ssh

0 commit comments

Comments
 (0)