| 1 | #!/bin/sh |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | set -eux |
| 7 | |
| 8 | |
| 9 | |
| 10 | if [ "${LIMA_CIDATA_NAME}" = "default" ] && command -v patch >/dev/null 2>&1 && grep -q color_prompt "${LIMA_CIDATA_HOME}/.bashrc"; then |
| 11 | |
| 12 | ! grep -q "^# Lima PS1" "${LIMA_CIDATA_HOME}/.bashrc" || exit 0 |
| 13 | |
| 14 | |
| 15 | |
| 16 | patch --forward -r - "${LIMA_CIDATA_HOME}/.bashrc" <<'EOF' |
| 17 | @@ -37,7 +37,11 @@ |
| 18 | |
| 19 | |
| 20 | case "$TERM" in |
| 21 | - xterm-color|*-256color) color_prompt=yes;; |
| 22 | + xterm-color) color_prompt=yes;; |
| 23 | + *-256color) color_prompt=256;; |
| 24 | +esac |
| 25 | +case "$COLORTERM" in |
| 26 | + truecolor) color_prompt=true;; |
| 27 | esac |
| 28 | |
| 29 | |
| 30 | @@ -56,7 +60,12 @@ |
| 31 | fi |
| 32 | fi |
| 33 | |
| 34 | -if [ "$color_prompt" = yes ]; then |
| 35 | +# Lima PS1: set color to lime green |
| 36 | +if [ "$color_prompt" = true ]; then |
| 37 | + PS1='${debian_chroot:+($debian_chroot)}\[\033[38;2;50;205;50m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' |
| 38 | +elif [ "$color_prompt" = 256 ]; then |
| 39 | + PS1='${debian_chroot:+($debian_chroot)}\[\033[38;5;77m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' |
| 40 | +elif [ "$color_prompt" = yes ]; then |
| 41 | PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' |
| 42 | else |
| 43 | PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' |
| 44 | EOF |
| 45 | |
| 46 | fi |