Skip to content

Change the default prompt color from green to lime #433

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 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 43 additions & 0 deletions pkg/cidata/cidata.TEMPLATE.d/boot/08-shell-prompt.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions pkg/cidata/cidata.TEMPLATE.d/lima.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
LIMA_CIDATA_NAME={{ .Name }}
LIMA_CIDATA_USER={{ .User }}
LIMA_CIDATA_UID={{ .UID }}
LIMA_CIDATA_MOUNTS={{ len .Mounts }}
Expand Down