-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdotfiles.sh
executable file
·55 lines (47 loc) · 937 Bytes
/
dotfiles.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
#!/bin/bash
export BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source ${BASEDIR}/config/shell/shell-functions.sh
available_tasks=()
for task in $(ls "$BASEDIR/setup")
do
if [[ "$task" != "_common.sh" ]]
then
available_tasks+=("${task%.sh}")
fi
done
if [[ $# -lt 1 ]]
then
echo "Usage $(basename "$0") [task] ..."
echo
echo "List of tasks:"
for task in "${available_tasks[@]}"
do
echo -n "- "
font_blue
echo "$task"
font_normal
done
echo
echo -n "Alternatively, use special task '"
font_blue
echo -n "all"
font_normal
echo "' to run all of them."
exit 0
fi
tasks_to_do=($@)
if [[ $# == 1 ]] && [[ "$1" == "all" ]]
then
tasks_to_do=(${available_tasks[@]})
fi
for task in "${tasks_to_do[@]}"
do
script="$BASEDIR/setup/$task.sh"
if [[ ! -f "$script" ]]
then
echo_red "File '$script' does not exist."
exit 1
fi
bash "$script"
done
echo_green "Done."