-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·204 lines (174 loc) · 5.5 KB
/
bootstrap.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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#!/usr/bin/env bash
setup_aerospace() {
echo "Setting up AeroSpace configuration..."
local aerospace_config_dir="$HOME/.config/aerospace"
local aerospace_config_file="$aerospace_config_dir/aerospace.toml"
local source_config_file="$PWD/.config/aerospace/aerospace.toml"
# Ensure the target directory exists
mkdir -p "$aerospace_config_dir"
# Create symlink for the configuration file
ln -sf "$source_config_file" "$aerospace_config_file"
echo "AeroSpace configuration symlinked successfully."
}
setup_tools() {
echo "Setting up additional command line tools..."
local tools=(
# Better ls replacement
eza
# Better find replacement
fd
# Smarter cd with directory jumping (better than z)
zoxide
# Simplified man pages
tldr
# Better disk usage viewer
duf
# Directory size analyzer
dust
# Modern cut replacement
choose
# Modern system monitor
bottom
# Modern replacement for dig (and dog)
doggo
# JSON processor
jq
# Modern process viewer
procs
# Modern grep alternative with type support
ripgrep-all
# Directory tree generator
tre-command
)
if ! command -v brew >/dev/null 2>&1; then
echo "Homebrew is not installed. Skipping tool installation."
return 1
fi
for tool in "${tools[@]}"; do
[[ -z "$tool" || "$tool" =~ ^[[:space:]]*# ]] && continue
if ! brew list "$tool" >/dev/null 2>&1; then
echo "Installing $tool..."
brew install "$tool"
else
echo "✓ $tool is already installed"
fi
done
}
setup_symlinks() {
echo "Setting symbolic links to various configs..."
local configs=(
.env
.bash_aliases
.bashrc_shared
.pam_environment
.zshrc
.psqlrc
.sqliterc
.inputrc
.tmux.conf
.gitignore
.Xresources
.secrets
.wezterm.lua
)
for config in "${configs[@]}"; do
ln -sf "$PWD/$config" "$HOME/$config"
done
}
setup_macos() {
echo "Setting up macOS-specific configurations..."
if [[ ! -f $HOME/.ssh/config ]]; then
mkdir -p "$HOME/.ssh"
ln -sf "$PWD/macOS/.ssh/config" "$HOME/.ssh/config"
fi
}
setup_linux() {
echo "Setting up Linux-specific configurations..."
MY_CONFIGS="$HOME/.config"
if [[ -f /etc/regolith/i3/config ]]; then
MY_CONFIGS="$HOME/.config/regolith"
fi
setup_linux_configs
mkdir -p "$MY_CONFIGS/i3"
ln -sf "$PWD/.config/i3/config" "$MY_CONFIGS/i3/config"
}
setup_linux_configs() {
mkdir -p "$MY_CONFIGS"
if [[ ! -f $MY_CONFIGS/openai.token ]]; then
ln -sf "$PWD/.config/openai.token" "$MY_CONFIGS/openai.token"
fi
mkdir -p "$MY_CONFIGS/i3status"
ln -sf "$PWD/.config/i3status/config" "$MY_CONFIGS/i3status/config"
mkdir -p "$MY_CONFIGS/conky"
ln -sf "$PWD/.config/conky/conky.conf" "$MY_CONFIGS/conky/conky.conf"
mkdir -p "$MY_CONFIGS/termite"
ln -sf "$PWD/.config/termite/config" "$MY_CONFIGS/termite/config"
}
setup_alacritty() {
echo "Setting up Alacritty configuration..."
local alacritty_config_dir="$HOME/.config/alacritty"
local alacritty_config_file="$alacritty_config_dir/alacritty.toml"
local source_config_file="$PWD/.config/alacritty/alacritty.toml"
# Remove existing symlink or directory
if [[ -L "$alacritty_config_dir" || -d "$alacritty_config_dir" ]]; then
rm -rf "$alacritty_config_dir"
fi
# Create the directory
mkdir -p "$alacritty_config_dir"
# Check if we're in the dotfiles directory
if [[ "$PWD" == "$HOME/git/dotfiles" ]]; then
# We're in the dotfiles directory, so copy the file instead of symlinking
cp "$source_config_file" "$alacritty_config_file"
else
# Create symlink for the configuration file
ln -sf "$source_config_file" "$alacritty_config_file"
fi
echo "Alacritty configuration set up successfully."
}
setup_git() {
if command -v git >/dev/null 2>&1; then
if [[ ! -f $HOME/.gitconfig ]]; then
echo "Git configuration not found. Creating one..."
read -p "Set your Git name to 'Robert Claypool'? [y,N] " doit
case $doit in
y|Y) git config --global user.name 'Robert Claypool' ;;
*) ;;
esac
read -p "Set your Git email to '[email protected]'? [y,N] " doit
case $doit in
y|Y) git config --global user.email '[email protected]' ;;
*) ;;
esac
git config --global core.excludesfile ~/.gitignore
git config --global merge.tool vimdiff
echo "Run 'git config --global -e' to review/edit the configuration."
else
echo "Git configuration found."
fi
else
echo "Error: Cannot find Git. '.gitconfig' was not updated."
return 1
fi
}
main() {
setup_symlinks
echo "-----"
if [[ "$OSTYPE" == "darwin"* ]]; then
setup_macos
echo "-----"
setup_tools
echo "-----"
setup_aerospace
else
setup_linux
fi
echo "-----"
setup_alacritty
echo "-----"
setup_git
echo "-----"
echo "Open README.md and install ZSH plugins as described."
}
# Wrapping in main() can prevent partial execution if the script is sourced
# instead of executed.
main