Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
lima-vm
GitHub Repository: lima-vm/lima
Path: blob/master/pkg/cidata/cidata.TEMPLATE.d/boot/08-shell-prompt.sh
2658 views
1
#!/bin/sh
2
3
# SPDX-FileCopyrightText: Copyright The Lima Authors
4
# SPDX-License-Identifier: Apache-2.0
5
6
set -eux
7
8
# This script is only intended for the default.yaml image, which is based on Ubuntu LTS
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
# Change the default shell prompt from "green" to "lime green" (#32CD32)
15
16
patch --forward -r - "${LIMA_CIDATA_HOME}/.bashrc" <<'EOF'
17
@@ -37,7 +37,11 @@
18
19
# set a fancy prompt (non-color, unless we know we "want" color)
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
# uncomment for a colored prompt, if the terminal has the capability; turned
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
47
48