forked from ryanb/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 3
/
install
executable file
·70 lines (58 loc) · 1.26 KB
/
install
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
63
64
65
66
67
68
69
70
#!/bin/bash
set -o errexit
steps_dir="$(dirname "$0")/steps"
steps=(macos homebrew mise zsh ssh git ghostty kitty neovim zed bat)
red=$(tput setaf 1)
green=$(tput setaf 2)
reset=$(tput sgr0)
function echo_red {
echo -e "${red}${1}${reset}"
}
function echo_green {
echo -e "${green}${1}${reset}"
}
function link_file {
if [[ -L "$2" ]]; then
echo "$2 is already linked, skipping."
elif [[ -e "$2" ]]; then
echo_red "$2 already exists, skipping. (You might not want this, so check the file.)"
else
ln -s "$PWD/$1" "$2"
echo "Linked $2"
fi
}
function run_step {
echo
echo_green "Configuring $1..."
# shellcheck disable=SC1090
source "$steps_dir/$1.bash"
}
function run_all_steps {
for step in "${steps[@]}"; do
run_step "$step"
done
}
function usage {
echo "Usage:"
echo " export DOTFILES_ENV=home|work"
echo " install [step name]"
echo
echo "Run all steps:"
echo " install"
echo
echo "Run a single step:"
echo " install [step name]"
echo
echo "Available steps: ${steps[*]}"
exit 1
}
if [[ $DOTFILES_ENV != "home" && $DOTFILES_ENV != "work" ]]; then usage; fi
if [[ $1 == "-h" || $1 == "--help" ]]; then
usage
elif [[ -n $1 ]]; then
run_step "$1"
else
run_all_steps
fi
echo
echo_green "Install complete."