-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprecmd
54 lines (37 loc) · 1.02 KB
/
precmd
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
preexec () {
END=$SECONDS
}
precmd () {
# var
# color
RED='\e[31m'
BLUE='\e[34m'
BLACK='\e[30m'
GREEN='\e[32m'
PINK=%{$'\e[35m'%}
# bg
BG_YELLOW='\e[46m'
BG_PINK=%{$'\e[45m'%}
# mod
RESET=%{$'\e[m'%}
# cmd
START=$SECONDS
DATE=$(date +%d/%m/%y)
TIME=$(date +%H:%M:%S)
DIR=$(pwd | sed 's/\//⟫/g ; s/$/⟫/')
BAT=$(termux-battery-status | grep perc | tr -d '[a-z]":, ' | sed s/$/%/)
# calc
GAP=$(( COLUMNS - 2 ))
EXEC=$(( START - END ))
GAP_1=$(( COLUMNS - ${#BAT} - 12 ))
GAP_2=$(( COLUMNS - ${#DIR} - 12 ))
# prompt
PS1="$BG_PINK "$EXEC"s $RESET$PINK$RESET "
RPS1="$PINK$RESET$BG_PINK %(?;^^;--) $RESET"
# cmd
echo -n "$BG_YELLOW"
print "$RED╭${(l:$GAP::═:)}╮"
print "$GREEN║$BLACK : $BAT${(l:$GAP_1:)TIME} : $GREEN║"
print "$GREEN║$BLACK : $DIR${(l:$GAP_2:)DATE} : $GREEN║"
print "$BLUE╰${(l:$GAP::═:)}╯"
}