-
Notifications
You must be signed in to change notification settings - Fork 0
/
normandy-powerline.bash
97 lines (76 loc) · 1.68 KB
/
normandy-powerline.bash
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Normandy-powerline
RESET_FG="\e[39;21;24;25;27;28m"
NORMANDY_PL_RIGHT_SEPERATOR_FILLED_GLYPH='\uE0B0'
NORMANDY_PL_RIGHT_SEPERATOR_GLYPH='\uE0B1'
NORMANDY_PL_LEFT_SEPERATOR_FILLED_GLYPH='\uE0B2'
NORMANDY_PL_LEFT_SEPERATOR_GLYPH='\uE0B3'
__set_fg () {
echo -n "\e[38;5;$1m"
}
__unset_fg () {
echo -n "\e[39m"
}
__set_bg () {
echo -n "\e[48;5;$1m"
}
__unset_bg () {
echo -n "\e[49m"
}
__set_bold () {
echo -n "\e[1m"
}
__unset_bold () {
echo -n "\e[21"
}
__normandy_pl_unset_styling () {
echo -n "\e[39;21;24;25;27;28m"
}
__normandy_pl_exit_status () {
if [ $? -ne 0 ]; then
__set_fg 1 # red
__set_bold
echo -n "! "
__unset_bold
fi
}
__normandy_pl_job_status () {
if [ "$(jobs)" != "" ]; then
__set_fg 6 # cyan
echo -n "% "
fi
}
__normandy_pl_status_segment_content () {
echo -n "$(__normandy_pl_exit_status)$(__normandy_pl_job_status)"
}
PREV_SEGMENT_L_COLOR=""
__add_segment_seperator_l () {
PREV_SEGMENT_L_COLOR=""
NEW_SEGMENT_L_COLOR="$1"
echo "hiya! $NEW_SEGMENT_L_COLOR"
if [ "$PREV_SEGMENT_L_COLOR" == "" ]; then
__set_bg $NEW_SEGMENT_L_COLOR
echo -n " "
elif [ "$PREV_SEGMENT_L_COLOR" == "$NEW_SEGMENT_L_COLOR" ]; then
echo "TODO"
else
__set_bg $NEW_SEGMENT_L_COLOR
__set_fg $PREV_SEGMENT_L_COLOR
echo -n "$NORMANDY_PL_RIGHT_SEPERATOR_FILLED_GLYPH "
fi
PREV_SEGMENT_L_COLOR=$NEW_SEGMENT_L_COLOR
}
__normandy_pl_add_segment_l () {
CONTENT=$1
BG_COLOR=$2
if [ "$CONTENT" != "" ]; then
__add_segment_seperator_l $BG_COLOR
echo -n $CONTENT
fi
}
normandy_pl_prompt () {
__normandy_pl_add_segment_l $(__normandy_pl_status_segment_content) 15 # white
__unset_bg
__set_fg 15
echo -n "$NORMANDY_PL_RIGHT_SEPERATOR_FILLED_GLYPH "
__unset_fg
}