lima-vm / lima

Linux virtual machines, with a focus on running containers
https://lima-vm.io/
Apache License 2.0
15.19k stars 596 forks source link

RFC: Remove the color prompt overrides from default instance and shell environment for v1.0? #1892

Closed afbjorklund closed 1 year ago

afbjorklund commented 1 year ago

Description

We had an old issue, to make the lima prompt distinguishable from the host prompt.

The color was playing on the "lime" word game, and used a bright yellow-green (Lime)

Here the color(s) shown in Ubuntu terminal: ![lima-shell-color-prompt](https://user-images.githubusercontent.com/10364051/142941057-6ef7fdae-32da-4242-a298-c857e2e62c11.png)

But it requires 24-bit color support to look best, as an addition to 256 (or 16) colors support:

And it doesn't really work on light backgrounds, so requires support for the terminal "theme":


So I think the best would be to remove those changes, and go back to the original issue:

Go back to the original Ubuntu prompt:

-if [ "$color_prompt" = yes ]; then
-    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
+# Lima PS1: set color to lime
+if [ "$color_prompt" = true ]; then
+    PS1='${debian_chroot:+($debian_chroot)}\[\033[38;2;192;255;0m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
+elif [ "$color_prompt" = 256 ]; then
+    PS1='${debian_chroot:+($debian_chroot)}\[\033[38;5;154m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
+elif [ "$color_prompt" = yes ]; then
+    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;92m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
 else
     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
 fi

Note that the default prompt does have the host name in it, which does include "lima":

anders@lima-default:/home/anders$ uname
Linux

But it could be desired to change the prompt?

[ "$PS1" ] && PS1="[LIMA] $PS1"

afbjorklund commented 1 year ago

A compromise, if wanting to keep the color override, would be to go for "lime green"

It's not great on a light background, but you can at least make out the characters...


lima-green-lime-prompt

This makes it work also with the "light" themes, here showing base16-shell "default":

lima-color-base16-light

afbjorklund commented 1 year ago

Two issues:

cmd/limactl/shell.go:   if _, present := os.LookupEnv("COLORTERM"); present {
cmd/limactl/shell.go:           sshArgs = append(sshArgs, "-o", "SendEnv=\"COLORTERM\"")
# accept any incoming COLORTERM environment variable
sed -i 's/^AcceptEnv LANG LC_\*$/AcceptEnv COLORTERM LANG LC_*/' /etc/ssh/sshd_config

After that:

AkihiroSuda commented 1 year ago

I guess we can just remove the custom PS1

afbjorklund commented 1 year ago

I'm seeing lime green color everywhere, so think I will just keep it as it is now.

lime