-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·120 lines (100 loc) · 2.24 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·120 lines (100 loc) · 2.24 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env bash
SCRIPT_PATH=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=/dev/null
source "${SCRIPT_PATH}/shell/os.sh" || exit 1
for f in common symlinks packages-arch packages-wsl languages tools services; do
# shellcheck source=/dev/null
source "${SCRIPT_PATH}/setup/${f}.sh" || {
echo "Failed to source setup/${f}.sh" >&2
exit 1
}
done
usage() {
cat <<'EOF'
Usage: ./setup.sh [options]
Options:
--reinstall Wipe installed tool/runtime dirs, then run the full setup.
-h, --help Show this help.
With no options, runs the interactive flow: prompts for packages and tools,
then creates directories and symlinks.
EOF
}
reinstall() {
rm -rf ~/.{local/bin,npm,nvm,zinit,go/bin,config/composer/vendor,nvim,config/nvim}
}
run_packages() {
# TODO: support macOS
if [[ ! "${OSTYPE}" =~ ^linux ]]; then
return
fi
section_start 'Install packages? [y/n]'
read -r resp
if [ "${resp}" != 'y' ] && [ "${resp}" != 'Y' ]; then
return
fi
if is_arch; then
# shellcheck disable=2119
install_arch_packages
post_install_packages
setup_arch_services
post_setup_arch_services
elif is_wsl; then
install_wsl_packages
post_setup_wsl_services
fi
# shellcheck disable=2119
install_go_packages
# shellcheck disable=SC2119
install_pip_packages
}
run_tools() {
section_start 'Install tools? [y/n]'
read -r resp
if [ "${resp}" != 'y' ] && [ "${resp}" != 'Y' ]; then
return
fi
install_zinit
install_tpm
# shellcheck disable=SC2119
install_node_packages
install_composer
}
run_links() {
section_start 'Symlink dotfiles? [y/n]'
read -r resp
if [ "${resp}" != 'y' ] && [ "${resp}" != 'Y' ]; then
echo 'Symlinking cancelled by user'
return
fi
init_links
echo "Symlinking complete. Backups stored in ${SCRIPT_PATH}/backups."
}
main() {
case "${1:-}" in
-h | --help)
usage
return 0
;;
--reinstall)
reinstall
;;
'') ;;
*)
echo "Unknown option: ${1}" >&2
usage
return 1
;;
esac
section_start "Running from ${PWD}"
run_packages
run_tools
init_dirs
run_links
if [[ "${SHELL}" != */zsh ]]; then
chsh -s "$(command -v zsh)"
command zsh
else
echo 'Restart your terminal'
fi
}
main "$@"