-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
executable file
·60 lines (49 loc) · 1.25 KB
/
start.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
52
53
54
55
56
57
58
59
60
#!/bin/bash
sleep 0.1
BASE_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
center() {
echo ""
termwidth="$(tput cols)"
padding="$(printf '%0.1s' ' '{1..500})"
printf '%*.*s %s %*.*s\n' 0 "$(((termwidth-2-${#1})/2))" "$padding" "$1" 0 "$(((termwidth-1-${#1})/2))" "$padding"
echo ""
}
tput bold
center 'Activity Logger'
center ' --- Commands: --- '
tput sgr0
available_activites=$(watson projects)
available_activites="no_activity start_new_activity remove_activity stop_activity ${available_activites}"
stringarray=($available_activites)
for i in "${!stringarray[@]}"
do
echo " "$i"." "${stringarray[$i]}"
if (($i == 3)); then
tput bold
center ' --- Activities: --- '
tput sgr0
fi
done
tput bold
center " --- "
tput sgr0
echo "Selection [index]:"
read indexSelection
if ! [[ "$indexSelection" =~ ^[0-9]+$ ]] ;
then exec >&2; echo "Error: Not a number"; clear; ./$0
fi
if (($indexSelection > 3)); then
echo
watson start ${stringarray[$indexSelection]}
sleep 3
exit 1
fi
if (($indexSelection == 1)); then
$BASE_DIR/start_new_activity.sh
fi
if (($indexSelection == 2)); then
$BASE_DIR/remove_activity.sh
fi
if (($indexSelection == 3)); then
$BASE_DIR/stop.sh
fi