diff --git a/docs/internal.md b/docs/internal.md index d6cd3cc7c0f..0884377fab3 100644 --- a/docs/internal.md +++ b/docs/internal.md @@ -102,6 +102,7 @@ Max file name length = 30 The volume label is "cidata", as defined by [cloud-init NoCloud](https://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html). ### Environment variables +- `LIMA_CIDATA_NAME`: the lima instance name - `LIMA_CIDATA_MNT`: the mount point of the disk. `/mnt/lima-cidata`. - `LIMA_CIDATA_USER`: the user name string - `LIMA_CIDATA_UID`: the numeric UID diff --git a/pkg/cidata/cidata.TEMPLATE.d/boot/08-shell-prompt.sh b/pkg/cidata/cidata.TEMPLATE.d/boot/08-shell-prompt.sh new file mode 100644 index 00000000000..d351f9f277e --- /dev/null +++ b/pkg/cidata/cidata.TEMPLATE.d/boot/08-shell-prompt.sh @@ -0,0 +1,43 @@ +#!/bin/sh +set -eux + +if [ "${LIMA_CIDATA_NAME}" = "default" ]; then + + ! grep -q "^# Lima PS1" "/home/${LIMA_CIDATA_USER}.linux/.bashrc" || exit 0 + + # Change the default shell prompt from "green" to "lime" (#BFFF00) + + patch --forward -r - "/home/${LIMA_CIDATA_USER}.linux/.bashrc" <<'EOF' +@@ -37,7 +37,11 @@ + + # set a fancy prompt (non-color, unless we know we "want" color) + case "$TERM" in +- xterm-color|*-256color) color_prompt=yes;; ++ xterm-color) color_prompt=yes;; ++ *-256color) color_prompt=256;; ++esac ++case "$COLORTERM" in ++ truecolor) color_prompt=true;; + esac + + # uncomment for a colored prompt, if the terminal has the capability; turned +@@ -56,8 +60,13 @@ + fi + fi + +-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 +fi +EOF + +fi diff --git a/pkg/cidata/cidata.TEMPLATE.d/lima.env b/pkg/cidata/cidata.TEMPLATE.d/lima.env index 3478dd03f9e..f36b8bcc31a 100644 --- a/pkg/cidata/cidata.TEMPLATE.d/lima.env +++ b/pkg/cidata/cidata.TEMPLATE.d/lima.env @@ -1,3 +1,4 @@ +LIMA_CIDATA_NAME={{ .Name }} LIMA_CIDATA_USER={{ .User }} LIMA_CIDATA_UID={{ .UID }} LIMA_CIDATA_MOUNTS={{ len .Mounts }}