-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstyle_functions
More file actions
executable file
·118 lines (101 loc) · 2.33 KB
/
style_functions
File metadata and controls
executable file
·118 lines (101 loc) · 2.33 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/env bash
###########################################################
# Appearance
###########################################################
# BLACK=30, RED=31, GREEN=32, YELLOW=33, BLUE=34, PINK=35, CYAN=36, WHITE=37
# Examples of colored boxes (default colors)
# title "Testing a title box"
# info "Testing an information box"
# warning "Testing a warning box"
# error "Testing an error box"
# colorize "text message" #fg #bg #format
# Terminal size
export COLUMNS=`tput cols`
# a black
# b red
# c green
# d brown
# e blue
# f magenta
# g cyan
# h light grey
# A bold black, usually shows up as dark grey
# B bold red
# C bold green
# D bold brown, usually shows up as yellow
# E bold blue
# F bold magenta
# G bold cyan
# H bold light grey; looks like bright white
# x default foreground or background
# 1. directory
# 2. symbolic link
# 3. socket
# 4. pipe
# 5. executable
# 6. block special
# 7. character special
# 8. executable with setuid bit set
# 9. executable with setgid bit set
# 10. directory writable to others, with sticky bit
# 11. directory writable to others, without sticky
export CLICOLOR=1
# export LSCOLORS=ExFxCxDxBxegedabagaced
# Default color values
D_FG=39
D_BG=49
D_FM=0
# Colors
export BLUE="\e[0;34m"
export CYAN="\e[0;36m"
export GRAY="\e[1;30m"
export GREEN="\e[0;32m"
export PINK="\e[0;35m"
export RED="\e[0;31m"
export WHITE="\e[1;37m"
export YELLOW="\e[0;33m"
export NC="\e[0m" # no color
_style_colorize () {
[ -n "$1" ] || return 65;
local FC="\033["
local RC="\033[0m"
[ -n "$4" ] && FC="${FC}${4};" || FC="${FC}${D_FM};"
[ -n "$2" ] && FC="${FC}${2};" || FC="${FC}${D_FG};"
[ -n "$3" ] && FC="${FC}${3}m" || FC="${FC}${D_BG}m"
msg="$1"
echo -en "${FC}${msg}${RC}";
}
_style_center () {
msg=" $1 ";
while [ ${#msg} -lt $COLUMNS ]; do
[ $((${#msg} % 2)) -eq 0 ] && msg="$msg " || msg=" $msg"
done
}
_style_banner () {
msg=" $1 ";
while [ ${#msg} -lt $COLUMNS ]; do
msg="$msg "
done
}
_style_banner_right () {
msg=" $1 ";
while [ ${#msg} -lt $COLUMNS ]; do
msg=" $msg"
done
}
_style_title () {
_style_banner "$1";
_style_colorize "$msg" 30 42 1
}
_style_warning () {
_style_banner "$1";
_style_colorize "$msg" 30 43 1
}
_style_error () {
_style_banner "$1";
_style_colorize "$msg" 37 41 1
}
_style_info () {
_style_banner "$1";
_style_colorize "$msg" 34 47 1
}