-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·144 lines (128 loc) · 3.71 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·144 lines (128 loc) · 3.71 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
140
141
142
143
144
#!/bin/bash
check_requirements() {
required_clis=("brew" "git" "rsync")
for cli in "${required_clis[@]}"; do
if ! command -v "$cli" &>/dev/null; then
echo "Error: $cli is not installed. Please install it before running this script."
exit 1
fi
done
}
# Clone dotfiles from repo
setup_dotfiles() {
# CONFIG MAKE SURE
XDG_CONFIG_DIR="$HOME/.config"
mkdir -p "$XDG_CONFIG_DIR"
# Sync dotfiles
echo "Cloning dotfiles repository..."
if git clone --separate-git-dir="$HOME"/.dotfiles https://github.com/anandpiyer/.dotfiles.git tmpdotfiles; then
echo "Successfully cloned dotfiles repository"
if rsync --recursive --verbose --exclude '.git' tmpdotfiles/ "$HOME"/; then
echo "Successfully synced dotfiles"
rm -rf tmpdotfiles
else
echo "Error: Failed to sync dotfiles"
rm -rf tmpdotfiles
return 1
fi
else
echo "Error: Failed to clone dotfiles repository"
return 1
fi
}
# Installing dev packages and tooling with brew + setting up oh-my-zsh/plugins
setup_dev_env() {
# NOTE: Update as needed (i.e. tmux, zsh may be missing from base OS)
brew_packages=(
"atuin"
"awscli"
"bat"
"carapace"
"eza"
"fd"
"fzf"
"git-delta"
"gh"
"go"
"helm"
"inxi"
"kind"
"kubernetes-cli"
"lazydocker"
"lazygit"
"mkcert"
"mise"
"neovim"
"opencode"
"opentofu"
"ripgrep"
"sesh"
"uv"
"viu"
"yazi"
"zoxide"
)
brew_taps=(
"hashicorp/tap"
)
failed_taps=()
for tap in "${brew_taps[@]}"; do
echo "Adding brew tap: $tap..."
if ! brew tap "$tap"; then
echo "Warning: Failed to add tap $tap"
failed_taps+=("$tap")
fi
done
if [ ${#failed_taps[@]} -gt 0 ]; then
echo "Failed to add the following taps: ${failed_taps[*]}"
fi
failed_packages=()
for package in "${brew_packages[@]}"; do
echo "Installing $package via brew..."
if ! brew install "$package"; then
echo "Warning: Failed to install $package"
failed_packages+=("$package")
fi
done
if [ ${#failed_packages[@]} -gt 0 ]; then
echo "Failed to install the following packages: ${failed_packages[*]}"
fi
# Installing oh-my-zsh AND plugins (non-interactive)
echo "Installing oh-my-zsh..."
if [ ! -d "$HOME/.oh-my-zsh" ]; then
RUNZSH=no CHSH=no sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
if [ $? -eq 0 ]; then
echo "Successfully installed oh-my-zsh"
else
echo "Error: Failed to install oh-my-zsh"
return 1
fi
else
echo "oh-my-zsh already installed, skipping..."
fi
# Install zsh plugins
echo "Installing zsh plugins..."
ZSH_CUSTOM_DIR="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
if [ ! -d "$ZSH_CUSTOM_DIR/plugins/zsh-autosuggestions" ]; then
if git clone https://github.com/zsh-users/zsh-autosuggestions "$ZSH_CUSTOM_DIR/plugins/zsh-autosuggestions"; then
echo "Successfully installed zsh-autosuggestions"
else
echo "Error: Failed to install zsh-autosuggestions"
fi
else
echo "zsh-autosuggestions already installed, skipping..."
fi
if [ ! -d "$ZSH_CUSTOM_DIR/plugins/zsh-syntax-highlighting" ]; then
if git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$ZSH_CUSTOM_DIR/plugins/zsh-syntax-highlighting"; then
echo "Successfully installed zsh-syntax-highlighting"
else
echo "Error: Failed to install zsh-syntax-highlighting"
fi
else
echo "zsh-syntax-highlighting already installed, skipping..."
fi
}
# Main script execution
echo Setting up config files utilities for new machine...
check_requirements && setup_dotfiles && setup_dev_env
echo "Done setting up dev environment on $(cat /etc/os-release) :)"