-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·130 lines (106 loc) · 2.58 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
#!/bin/bash
set -euo pipefail # Exit on error, undefined vars, and pipeline failures
# Colors for output
readonly GREEN='\033[0;32m'
readonly NC='\033[0m' # No Color
# Configuration
readonly DOTFILES_DIR="$HOME/dotfiles"
readonly DOTFILES_REPO="https://github.com/WTFox/dotfiles.git"
# Helper functions
log() {
echo -e "${GREEN}$1${NC}"
}
maintain_sudo() {
sudo -v
while true; do
sudo -n true
sleep 60
kill -0 "$$" || exit
done 2>/dev/null &
}
install_git() {
if command -v git &>/dev/null; then
return 0
fi
log "Git not found. Installing git..."
if [[ "$(uname)" == "Darwin" ]]; then
if ! command -v brew &>/dev/null; then
log "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
brew install git
else
sudo apt-get update
sudo apt-get install -y git
fi
}
setup_dotfiles() {
if [ ! -d "$DOTFILES_DIR" ]; then
log "Cloning dotfiles repository..."
git clone "$DOTFILES_REPO" "$DOTFILES_DIR"
else
log "Updating existing dotfiles..."
(cd "$DOTFILES_DIR" && git pull)
fi
}
configure_shell() {
local zsh_path
zsh_path="$(which zsh)"
if [ "$SHELL" = "$zsh_path" ]; then
log "zsh is already your default shell"
return 0
fi
log "Changing default shell to zsh..."
if ! grep -q "$zsh_path" /etc/shells; then
log "Adding zsh to /etc/shells..."
echo "$zsh_path" | sudo tee -a /etc/shells
fi
if ! sudo chsh -s "$zsh_path" "$USER"; then
log "Failed to change shell to zsh"
return 1
fi
log "Shell changed to zsh. Please log out and log back in for changes to take effect."
}
install_components() {
local osType
source ./_bootstrap/os/common.sh
osType=$(get_os_type)
source "./_bootstrap/os/${osType}.sh"
# Install core components
local components=(
"update_package_manager"
"install_git_and_gh"
"install_starship"
"install_fzf"
"install_stow"
"install_dotfiles"
"install_zsh_and_oh_my_zsh"
"install_zoxide"
"install_apps"
)
# Install programming languages and tools
local dev_tools=(
"install_python_and_pyenv"
"install_uv"
"install_node_and_nvm"
"install_rust"
"install_go"
"install_nvim"
)
for component in "${components[@]}" "${dev_tools[@]}"; do
log "Running $component..."
$component
done
}
main() {
log "Please enter your sudo password for setup:"
maintain_sudo
install_git
setup_dotfiles
cd "$DOTFILES_DIR"
install_components
log "All done! Please run configure_git manually."
configure_shell
./stow.sh
}
main