-
Notifications
You must be signed in to change notification settings - Fork 0
/
color_xterm.sh
executable file
·51 lines (43 loc) · 1.17 KB
/
color_xterm.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
51
#!/usr/bin/env bash
# ===============================================
# C O L O R X T E R M =
# ===============================================
#
# Launch randomed colorized xterminals
#
# ===============================================
# Exit when command fail
set -o errexit
# My fun colors
readonly XTERM_COLORS=(
'lightgreen'
'lime'
'skyblue'
'gold'
'coral'
)
# FG is BLACK !
readonly DEFAULT_FG_COLOR="black"
readonly XTERM_COLORS_SIZE=${#XTERM_COLORS[@]}
function main() {
local terms_number=1
if (( $# >= 1 )); then
# Check if param is an integer
if [[ $1 =~ ^[0-9]+$ ]]; then
terms_number=$1
else
echo "Usage: color_xterm [number]"
exit 1
fi
fi
local counter=0
while (( counter < terms_number )); do
local selected_color=${XTERM_COLORS[$((RANDOM%XTERM_COLORS_SIZE))]}
xterm -bg "$selected_color" -fg "$DEFAULT_FG_COLOR" &
local counter=$(( counter + 1 ))
done
}
main "$@"
# ===============================================
# END: C O L O R X T E R M =
# ===============================================