-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathce
More file actions
executable file
·62 lines (58 loc) · 1.04 KB
/
Copy pathce
File metadata and controls
executable file
·62 lines (58 loc) · 1.04 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
#!/bin/sh
# Colourising echo output
usage(){
cat <<-EOF
Usage: ce {colour} message
colour list:
EOF
echo "-r|--red: \033[31mRed\033[0m"
echo "-g|--green: \033[32mGreen\033[0m"
echo "-y|--yellow: \033[33mYellow\033[0m"
echo "-b|--blue: \033[34mBlue\033[0m"
echo "-m|--magenta: \033[35mMagenta\033[0m"
echo "-c|--cyan: \033[36mCyan\033[0m"
echo "-w|--white: \033[37mWhite\033[0m"
exit 1
}
colour_echo(){
case $1 in
-r|--red)
shift
echo "\033[31m$@\033[0m"
;;
-g|--green)
shift
echo "\033[32m$@\033[0m"
;;
-y|--yellow)
shift
echo "\033[33m$@\033[0m"
;;
-b|--blue)
shift
echo "\033[34m$@\033[0m"
;;
-m|--magenta)
shift
echo "\033[35m$@\033[0m"
;;
-c|--cyan)
shift
echo "\033[36m$@\033[0m"
;;
-w|--white)
shift
echo "\033[37m$@\033[0m"
;;
*)
echo "No such argument"
usage
;;
esac
}
if [ $# -lt 2 ]; then
echo "Invalid argument."
usage
else
colour_echo "$@"
fi