Skip to content

Commit

Permalink
Merge pull request #433 from afbjorklund/shell-prompt
Browse files Browse the repository at this point in the history
Change the default prompt color from green to lime
  • Loading branch information
jandubois authored Dec 3, 2021
2 parents 4f87407 + 72a8c37 commit b63d499
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
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

0 comments on commit b63d499

Please sign in to comment.