-
Notifications
You must be signed in to change notification settings - Fork 15
/
utils.sh
50 lines (40 loc) · 1.01 KB
/
utils.sh
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
#!/bin/sh
: ==========================================
: Installation utilities
: ==========================================
# This file contains utility functions to be used within the
# Sublime installation scripts.
color_default="0m"
color_info="94m" # blue
color_success="92m" # green
color_warning="93m" # yellow
color_error="91m" # red
# prints colored text
print_color() {
if [ "$2" = "info" ]; then
COLOR="$color_info"
elif [ "$2" = "success" ]; then
COLOR="$color_success"
elif [ "$2" = "warning" ]; then
COLOR="$color_warning"
elif [ "$2" = "error" ]; then
COLOR="$color_error"
else #default color
COLOR="$color_default"
fi
STARTCOLOR="\e[$COLOR"
ENDCOLOR="\e[$color_default"
printf "${STARTCOLOR}%b${ENDCOLOR}" "$1"
}
print_error() {
print_color "\n$1\n" "error"
}
print_success() {
print_color "\n$1\n" "success"
}
print_info() {
print_color "\n$1\n" "info"
}
print_warning() {
print_color "\n$1\n" "warning"
}