-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·139 lines (122 loc) · 3.36 KB
/
install.sh
File metadata and controls
executable file
·139 lines (122 loc) · 3.36 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/usr/bin/bash
DEB_PKGS=(
"git"
"zsh"
"htop"
"neovim"
"python3-neovim"
"build-essential"
"cmake"
"python3-dev"
"i3"
"i3status"
"dmenu"
"feh"
)
RH_PKGS=(
"git"
"zsh"
"neovim"
"python3-neovim"
"@development-tools"
)
declare -A DOTFILES_MAP
DOTFILES_MAP["zed"]="$HOME/.zed"
DOTFILES_MAP["claude"]="$HOME/.claude"
DOTFILES_MAP["nvim"]="$HOME/.config/nvim"
DOTFILES_MAP["alacritty.toml"]="$HOME/.config/alacritty/alacritty.toml"
DOTFILES_MAP["zsh/rc"]="$HOME/.zshrc"
DOTFILES_MAP["zsh/env"]="$HOME/.zsh_env"
DOTFILES_MAP["zsh/aliases"]="$HOME/.zsh_aliases"
DOTFILES_MAP[".tmux.conf"]="$HOME/.tmux.conf"
DOTFILES_MAP[".gitconfig"]="$HOME/.gitconfig"
DOTFILES_MAP[".lynx.cfg"]="$HOME/.lynx.cfg"
DOTFILES_MAP[".lynx.lss"]="$HOME/.lynx.lss"
# AeroSpace config is version-controlled on every machine; only macOS
# actually consumes it, but keeping the symlink cross-platform is harmless
# and means the file stays in sync if you ever edit it from Linux.
DOTFILES_MAP[".aerospace.toml"]="$HOME/.aerospace.toml"
is_macos() {
[[ "$(uname)" == "Darwin" ]]
}
# On Linux systems we also manage the i3wm config.
if ! is_macos; then
DOTFILES_MAP["i3/config"]="$HOME/.config/i3/config"
DOTFILES_MAP["i3/i3status"]="$HOME/.config/i3status/config"
fi
get_pkg_manager() {
if command -v apt &> /dev/null; then
echo "apt"
elif command -v dnf &> /dev/null; then
echo "dnf"
elif command -v brew &> /dev/null; then
echo "brew"
else
echo ""
fi
}
install_pkgs() {
local skip=$1
if $skip; then
echo "skipping pkg installation as --skip-pkg-install was provided"
return 0
fi
pkg_manager="$(get_pkg_manager)"
echo "installing dependencies for ${pkg_manager}"
case $pkg_manager in
"apt")
sudo apt update -y && sudo apt install -y "${DEB_PKGS[@]}"
return 0
;;
"dnf")
sudo dnf update -y && sudo dnf install -y "${RH_PKGS[@]}"
return 0
;;
"brew")
# Casks need `--cask`; the tap prefix in BREW_CASKS triggers
# `brew tap` implicitly on first install.
brew install --cask "${BREW_CASKS[@]}"
return 0
;;
*)
echo "failed to detect system's package manager: ${pkg_manager}"
return 1
;;
esac
}
create_symlinks() {
for file in "${!DOTFILES_MAP[@]}"; do
echo "creating symlink for $file at ${DOTFILES_MAP[$file]}"
ln -s "$(pwd)/$file" "${DOTFILES_MAP[$file]}"
done
}
main() {
skip_pkgs=false
while [[ "$1" != "" ]]; do
case $1 in
--skip-pkg-install)
skip_pkgs=true
;;
*)
echo "unrecognized flag: only --skip-pkg-install is supported"
exit 1
esac
shift
done
if ! install_pkgs $skip_pkgs; then
exit $?
fi
echo "preparing environment to symlink dotfiles"
mkdir -p "$HOME/.config/zed/"
mkdir -p "$HOME/.config/claude/"
mkdir -p "$HOME/.config/nvim/"
mkdir -p "$HOME/.config/alacritty/"
if ! is_macos; then
mkdir -p "$HOME/.config/i3/"
mkdir -p "$HOME/.config/i3status/"
fi
create_symlinks
echo "Neovim will require installing LSPs to work properly"
return 0
}
main "$@"