-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinfo_bar_installer
executable file
·69 lines (67 loc) · 3.33 KB
/
info_bar_installer
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
#!/bin/bash
name=.info_bar
case $1 in -[Rr]|--[Rr]emove)
sed -i "/$name/d" ~/.bashrc
[[ -e ~/$name ]] && rm ~/$name
exit 0;;
esac
grep -q "$name" ~/.bashrc && { echo 'Already installed!)'; exit 1; }
cat >> ~/.bashrc <<< ". ~/$name"
cat > ~/$name << 'EOF'
#---------------------------------------------{ Info bar }---------------------------------------------
boobs=(
'(* ) ( *)'
'(* )( *)'
'(*Y*)'
'(*|*)'
'( *)(* )'
'(* ) ( *)'
)
bn=${#boobs[@]} linesymbol='-' git_sts_depth=50
#-----------+------------+------------+--------{ Colors }-------+-----------+-----------+-------------+
# red | green | yelow | blue | magenta | default | bolded | dimed |
#-----------+------------+------------+------------+------------+-----------+-----------+-------------+
RED='\e[31m' GRN='\e[32m' YLW='\e[33m' BLU='\e[34m' MGN='\e[35m' DEF='\e[0m' BLD='\e[1m' DIM='\e[2m' #|
#-----------+------------+------------+------------+------------+-----------+-----------+-------------+
boob () { printf "${boobs[$[RANDOM%bn]]}"; }
info () { error=$? git_tst= git_clr=
[[ -d .git ]] && {
git_tst=($(git -c color.ui=never status -sb | head -$git_sts_depth)) git_tst="GIT ${git_tst[*]}" #Test output
git_clr=($(git -c color.ui=always status -sb | head -$git_sts_depth)) git_clr="GIT ${git_clr[*]}" #Colored output
}
[[ $debian_chroot ]] && chrt="($debian_chroot)" || chrt= # If in chroot
(( error > 0 )) && ncolor=$RED || ncolor=$YLW
name="$DEF$USER ${DIM}on $DEF$HOSTNAME$chrt $DEF$GRN}"
boob="$(boob)"
name_length="$USER on $HOSTNAME$chrt }"
boob_length="{ $boob }"
printf -v date "%(%a %d %b %T)T"
date_length="{ $date"
top_line_left=$[(COLUMNS-${#boob_length})/2]
top_line_left=$[top_line_left-${#name_length}]
top_line_right=$[COLUMNS-(top_line_left+${#name_length}+${#boob_length})]
top_line_right=$[top_line_right-${#date_length}]
boob=${boob//\*/$ncolor\*$DEF$BLD}
boob="{ $DEF$BLD$boob${DEF} $GRN}"
date="{ $DEF$DIM$date$DEF"
printf -v top_line "_NAME_%${top_line_left}s_BOOB_%${top_line_right}s_DATE_"
printf -v bot_line "%${COLUMNS}s"
top_line=${top_line// /-}
top_line=${top_line//_NAME_/"$name"}
top_line=${top_line//_BOOB_/"$boob"}
top_line=${top_line//_DATE_/"$date"}$DEF
bot_line=$GRN${bot_line// /-}$DEF
spaces=$[COLUMNS-${#PWD}-${#git_tst}]; ((spaces<0)) && spaces=1
#----------+-----------------+--------+---------+-------------+
# Top Line | Current dir | Spaces |GitStatus| Bottom Line |
#----------+-----------------+--------+---------+-------------+
printf "$top_line\n$BLD$BLU$PWD$DEF%${spaces}s$git_clr\n$bot_line"
}
#------------------------------------------------------------------------------------------------------
PS1='\n$(info)\n$ '; case "$TERM" in xterm*|rxvt*) PS1="\[\e]0;$(boob) \h\w\a\]$PS1";; esac
#------------------------------------------------------------------------------------------------------
EOF
# new layout scheme 'boobs'
#user on hostname }----------------------------{ (* )( *) }------------------------{ Пн 28 сен 14:22:19
#/home/vaniac/ower
#------------------------------------------------------------------------------------------------------