-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·54 lines (48 loc) · 1.73 KB
/
install.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
#!/usr/bin/env bash
# Script for installing LudvigHz dotfiles: http://github.com/LudvigHz/dotfiles
# Set dotfiles directory
DOTFILES="$(pwd)"
# Create a directory for local files
if [[ ! -d $DOTFILES/.local ]]; then
mkdir "$DOTFILES/.local"
fi
# Create a seperate file for global constants to not reset any local file used by
# another installation.
echo "export DOTFILES=$DOTFILES" >"$DOTFILES/.local/constants"
# shellcheck source=.local/constants
source "$DOTFILES/.local/constants"
# Declare a table of install scripts
declare -A install_scripts=(
["zsh"]="$DOTFILES/install/zsh.sh"
["zsh-update"]="$DOTFILES/install/zsh_update.sh"
["vim"]="$DOTFILES/install/vim.sh"
["tmux"]="$DOTFILES/install/tmux.sh"
["urxvt"]="$DOTFILES/install/urxvt.sh"
["alacritty"]="$DOTFILES/install/alacritty.sh"
["cli-tools"]="$DOTFILES/install/cli-tools.sh"
)
# Options for running the script automatically
declare -A install_scripts_opts=(
["cli-tools"]="-a"
)
# Run provided install scripts
if [[ -n $1 && -n "${install_scripts["$1"]}" ]]; then
echo -e "\e[1mStarting $1 installation process...\e[0m\n"
chmod +x "${install_scripts["$1"]}"
${install_scripts["$1"]} "$@"
# Run all scripts on -a or --all
elif [[ $1 == "-a" || $1 == "--all" ]]; then
for script in "${!install_scripts[@]}"; do
chmod +x "${install_scripts["$script"]}"
# Run the script, with options declared in $install_scripts_opts
${install_scripts["$script"]} "${install_scripts_opts["$script"]}"
done
else
# Output a help message if no args are provided
echo "Usage: $0 [program]
where [program] is one of the following:"
for i in "${!install_scripts[@]}"; do
printf "\t%s\n" "$i"
done
printf "\t-a|--all\tRun all install scripts (Install everything)\n"
fi