-
Notifications
You must be signed in to change notification settings - Fork 0
/
z_showinfo
36 lines (34 loc) · 1.35 KB
/
z_showinfo
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
# Text color variables
txtund=$(tput sgr 0 1) # Underline
txtbld=$(tput bold) # Bold
bldred=${txtbld}$(tput setaf 1) # red
bldblu=${txtbld}$(tput setaf 4) # blue
bldwht=${txtbld}$(tput setaf 7) # white
txtrst=$(tput sgr0) # Reset
info=${bldwht}*${txtrst} # Feedback
pass=${bldblu}*${txtrst}
warn=${bldred}*${txtrst}
ques=${bldblu}?${txtrst}
centralizeme(){
empty=" "
line=$@
chrcount=${#line}
#chrcount=${#line}
width=${COLUMNS}
paddingnum=$((width / 2 - chrcount / 2 ))
paddingnum=$((width / 2 - chrcount / 2 ))
[ "$width" -gt "$chrcount" ] && padding=${empty:0:$paddingnum} || padding=""
echo "$padding$@"
}
while read line
do
if [[ $line =~ ^"<und>" ]]; then
#http://askubuntu.com/questions/89995/bash-remove-first-and-last-characters-from-a-string
trimline=${line:5}
echo -n " " # To offset special tput string
centralizeme "$(tput sgr 0 1)${txtbld}$(tput setaf 3)$(tput setab 7)$trimline$(tput sgr0)"
else
centralizeme $line
fi
done < /home/znatz/.bash_custom.d/INFORMATION
echo -en "$(tput sgr0)"