Skip to content

Add COLORTERM to the lima shell environment #435

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

Merged
merged 1 commit into from
Dec 13, 2021

Conversation

afbjorklund
Copy link
Member

If the variable is set on the host, forward it.

Typical value if set would be COLORTERM=truecolor

Closes #434

@AkihiroSuda
Copy link
Member

Thanks, but CI failing

LIMA| Executing /mnt/lima-cidata/boot/11-colorterm-environment.sh
+ grep -q COLORTERM /etc/ssh/sshd_config
+ sed -i 's/^AcceptEnv LANG LC_\*$/AcceptEnv COLORTERM LANG LC_*/' /etc/ssh/sshd_config
+ test -f /sbin/openrc-init
+ command -v systemctl
+ systemctl reload ssh
Failed to reload ssh.service: Unit ssh.service not found.
LIMA| WARNING: Failed to execute /mnt/lima-cidata/boot/11-colorterm-environment.sh
LIMA| Executing /mnt/lima-cidata/boot/20-rootless-base.sh

https://cirrus-ci.com/task/4980033568636928

@afbjorklund

This comment has been minimized.

@afbjorklund

This comment has been minimized.

@AkihiroSuda
Copy link
Member

+ command -v systemctl
+ systemctl reload 'ssh*'
Failed to reload sshdgenkeys.service: Job type reload is not applicable for unit sshdgenkeys.service.
LIMA| WARNING: Failed to execute /mnt/lima-cidata/boot/11-colorterm-environment.sh

https://cirrus-ci.com/task/5709533226991616?logs=test#L478

@afbjorklund
Copy link
Member Author

Ah, Ok. Thanks for spotting it.

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]>
@AkihiroSuda AkihiroSuda requested a review from jandubois December 6, 2021 05:38
@jandubois
Copy link
Member

Looks good to me, but for some reason doesn't work:

$ COLORTERM=truecolor limactl --debug shell default
DEBU[0000] changeDirCmd="cd \"/Users/jan\" || cd \"/Users/jan\""
DEBU[0000] OpenSSH version 8.1.1 detected
DEBU[0000] AES accelerator seems available, prioritizing [email protected] and [email protected]
DEBU[0000] executing ssh (may take a long)): [/usr/bin/ssh -F /dev/null -o IdentityFile="/Users/jan/.lima/_config/user" -o IdentityFile="/Users/jan/.ssh/[REDACTED]" -o IdentityFile="/Users/jan/.ssh/[REDACTED]" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o NoHostAuthenticationForLocalhost=yes -o GSSAPIAuthentication=no -o PreferredAuthentications=publickey -o Compression=no -o BatchMode=yes -o IdentitiesOnly=yes -o Ciphers="^[email protected],[email protected]" -o User=jan -o ControlMaster=auto -o ControlPath="/Users/jan/.lima/default/ssh.sock" -o ControlPersist=5m -t -o SendEnv="COLORTERM" -q -p 60022 127.0.0.1 -- cd "/Users/jan" || cd "/Users/jan" ; exec bash --login]
jan@lima-default:/Users/jan$ sudo grep -B6 reload.ssh /var/log/cloud-init-output.log
LIMA| Executing /mnt/lima-cidata/boot/11-colorterm-environment.sh
+ grep -q COLORTERM /etc/ssh/sshd_config
+ sed -i s/^AcceptEnv LANG LC_\*$/AcceptEnv COLORTERM LANG LC_*/ /etc/ssh/sshd_config
+ [ -f /sbin/openrc-init ]
+ command -v systemctl
+ systemctl -q is-active ssh
+ systemctl reload ssh
jan@lima-default:/Users/jan$ grep COLORTERM /etc/ssh/sshd_config
AcceptEnv COLORTERM LANG LC_*
jan@lima-default:/Users/jan$ env | grep TERM
TERM=xterm-256color

I wonder if this is somehow related to this being a "lingering" session, so maybe environment variables aren't updated? I haven't looked further; @afbjorklund does this actually work for you?

Also wondering if this should be documented somewhere. Afaict, the only setting that would make any kind of difference would be COLORTERM=truecolor; all other values are ignored, right?

@afbjorklund
Copy link
Member Author

afbjorklund commented Dec 6, 2021

If you apply it to a running instance, you need to kill the ssh mux socket. It keeps the old ssh connection up.

~/.lima/default/ssh.sock

@afbjorklund
Copy link
Member Author

afbjorklund commented Dec 6, 2021

Afaict, the only setting that would make any kind of difference would be COLORTERM=truecolor; all other values are ignored, right?

I haven't seen any documentation, or any other value. The TERMTHEME variable name I totally made up myself.

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Eventually, we should ensure this to be configured before starting sshd

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

Successfully merging this pull request may close these issues.

Forward the setting of COLORTERM from the host to lima shell
3 participants