Skip to content

Commit c022e73

Browse files
authored
Merge pull request #435 from afbjorklund/colorterm
Add COLORTERM to the lima shell environment
2 parents 6ae76d8 + 418cb3e commit c022e73

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
set -eux
3+
4+
if grep -q "COLORTERM" /etc/ssh/sshd_config; then
5+
exit 0
6+
fi
7+
8+
# accept any incoming COLORTERM environment variable
9+
sed -i 's/^AcceptEnv LANG LC_\*$/AcceptEnv COLORTERM LANG LC_*/' /etc/ssh/sshd_config
10+
if [ -f /sbin/openrc-init ]; then
11+
rc-service --ifstarted sshd reload
12+
elif command -v systemctl >/dev/null 2>&1; then
13+
if systemctl -q is-active ssh; then
14+
systemctl reload ssh
15+
elif systemctl -q is-active sshd; then
16+
systemctl reload sshd
17+
fi
18+
fi

0 commit comments

Comments
 (0)