-
Notifications
You must be signed in to change notification settings - Fork 0
/
themeprompt
executable file
·66 lines (48 loc) · 1.17 KB
/
themeprompt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
# ref: https://github.com/devel0/knowledge/blob/8aed669981349d276fb23a0d2771893138869c44/doc/prompt-colors.md
themeprompt() {
fg=""
bg=""
case $1 in
prod)
fg=15
bg=160
;;
prod-user)
fg=160
;;
dev)
fg=16
bg=226
;;
dev-user)
fg=226
;;
test)
fg=15
bg=22
;;
test-user)
fg=22
;;
--help)
echo "specify one of follow profiles: prod prod-user dev dev-user test test-user"
return
;;
esac
if [ "$fg" == "" ] && [ "$1" != "" ] && (( $1 )); then
fg=$1
fi
if [ "$bg" == "" ] && [ "$2" != "" ] && (( $2 )); then
bg=$2
fi
# echo "using fg=$fg bg=$bg"
DEFAULT_PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
if [ "$fg" != "" ] && [ "$bg" != "" ]; then
PS1="$(echo $DEFAULT_PS1 | sed 's/01;32/1;38;5;${fg};48;5;${bg}/') "
elif [ "$fg" != "" ]; then
PS1="$(echo $DEFAULT_PS1 | sed 's/01;32/1;38;5;${fg}/') "
else
PS1=$DEFAULT_PS1
fi
}