-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·216 lines (195 loc) · 5.93 KB
/
setup.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
205
206
207
208
209
210
211
212
213
214
215
#!/bin/bash
# Ensure curl is installed for both Linux and macOS
ensure_curl() {
if ! command -v curl &> /dev/null; then
echo "curl is not installed. Installing now..."
case "$1" in
'Linux')
sudo apt-get update
sudo apt-get install curl -y
;;
'Darwin')
brew install curl
;;
*)
echo "Unsupported operating system for curl installation."
exit 1
;;
esac
echo "curl installed successfully."
else
echo "curl is already installed."
fi
}
# Function to install zsh on Debian-based Linux
install_zsh_debian() {
echo "Installing zsh on Debian-based Linux..."
sudo apt-get update
sudo apt-get install zsh -y
}
# Function to install zsh on macOS
install_zsh_macos() {
echo "Installing zsh on macOS..."
brew install zsh
}
# Install Oh My Zsh
install_oh_my_zsh() {
echo "Installing Oh My Zsh..."
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
}
# Function to install tmux on Debian-based Linux
install_tmux_debian() {
echo "Installing tmux on Debian-based Linux..."
sudo apt-get update
sudo apt-get install tmux -y
}
# Function to install tmux on macOS
install_tmux_macos() {
echo "Installing tmux on macOS..."
brew install tmux
}
# Adjusted function to install Neovim on Debian-based Linux by extracting the AppImage
install_nvim_linux() {
echo "Installing Neovim on Linux by extracting the AppImage..."
curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim.appimage
chmod u+x nvim.appimage
./nvim.appimage --appimage-extract
# Move the extracted directory to a more permanent location
sudo mv squashfs-root /opt/neovim-squashfs
# Create a symbolic link to the Neovim binary
sudo ln -s /opt/neovim-squashfs/usr/bin/nvim /usr/local/bin/nvim
echo "Neovim installed successfully."
}
# Function to install Neovim on macOS
install_nvim_macos() {
echo "Installing Neovim on macOS..."
brew install neovim
}
# Determine OS and ensure curl is installed
OS="`uname`"
ensure_curl $OS
# Check for zsh and install if not present
if ! command -v zsh &> /dev/null; then
echo "zsh is not installed. Checking operating system..."
case $OS in
'Linux')
install_zsh_debian
;;
'Darwin')
install_zsh_macos
;;
*)
echo "Unsupported operating system."
exit 1
;;
esac
echo "zsh installed successfully."
else
echo "zsh is already installed."
fi
# Set zsh as the default shell for the current user
if [ "$SHELL" != "$(which zsh)" ]; then
echo "Setting zsh as the default shell..."
chsh -s $(which zsh)
echo "zsh is now set as the default shell."
else
echo "zsh is already the default shell."
fi
# Check for Oh My Zsh and install if not present
if [ ! -d "$HOME/.oh-my-zsh" ]; then
install_oh_my_zsh
echo "Oh My Zsh installed successfully."
else
echo "Oh My Zsh is already installed."
fi
# Copy .zshrc and .oh-my-zsh/custom if they exist in the cwd
if [ -f "./.zshrc" ]; then
if [ -f "$HOME/.zshrc" ]; then
echo "Backing up existing .zshrc to .zshrc.backup"
mv "$HOME/.zshrc" "$HOME/.zshrc.backup"
fi
echo "Copying .zshrc to home directory."
cp "./.zshrc" "$HOME/"
fi
if [ -d "./.oh-my-zsh/custom" ]; then
if [ -d "$HOME/.oh-my-zsh/custom" ]; then
echo "Backing up existing .oh-my-zsh/custom to .oh-my-zsh/custom.backup"
mv "$HOME/.oh-my-zsh/custom" "$HOME/.oh-my-zsh/custom.backup"
fi
echo "Copying custom Oh My Zsh configurations."
cp -r "./.oh-my-zsh/custom" "$HOME/.oh-my-zsh/"
fi
# Check for tmux and install if not present
if ! command -v tmux &> /dev/null; then
echo "tmux is not installed. Checking operating system..."
case $OS in
'Linux')
install_tmux_debian
;;
'Darwin')
install_tmux_macos
;;
*)
echo "Unsupported operating system for tmux installation."
exit 1
;;
esac
echo "tmux installed successfully."
else
echo "tmux is already installed."
fi
# Install Tmux Plugin Manager (tpm) if not present
if [ ! -d "$HOME/.tmux/plugins/tpm" ]; then
echo "Tmux Plugin Manager (tpm) is not installed. Installing now..."
mkdir -p "$HOME/.tmux/plugins"
git clone https://github.com/tmux-plugins/tpm "$HOME/.tmux/plugins/tpm"
echo "tpm installed successfully."
else
echo "Tmux Plugin Manager (tpm) is already installed."
fi
# Copy .tmux and .tmux.conf if they exist in the cwd
if [ -d "./.tmux" ]; then
if [ -d "$HOME/.tmux" ]; then
echo "Backing up existing .tmux directory to .tmux.backup"
mv "$HOME/.tmux" "$HOME/.tmux.backup"
fi
echo "Copying .tmux directory."
cp -r "./.tmux" "$HOME/"
fi
if [ -f "./.tmux.conf" ]; then
if [ -f "$HOME/.tmux.conf" ]; then
echo "Backing up existing .tmux.conf to .tmux.conf.backup"
mv "$HOME/.tmux.conf" "$HOME/.tmux.conf.backup"
fi
echo "Copying .tmux.conf."
cp "./.tmux.conf" "$HOME/"
fi
# Check for Neovim and install if not present
if ! command -v nvim &> /dev/null; then
echo "Neovim is not installed. Checking operating system..."
case $OS in
'Linux')
install_nvim_linux
;;
'Darwin')
install_nvim_macos
;;
*)
echo "Unsupported operating system for Neovim installation."
exit 1
;;
esac
echo "Neovim installed successfully."
else
echo "Neovim is already installed."
fi
# Copy init.lua if it exists in the cwd
if [ -f "./init.lua" ]; then
if [ -f "$HOME/.config/nvim/init.lua" ]; then
echo "Backing up existing init.lua to init.lua.backup"
mv "$HOME/.config/nvim/init.lua" "$HOME/.config/nvim/init.lua.backup"
fi
echo "Copying init.lua to Neovim config directory."
mkdir -p "$HOME/.config/nvim"
cp "./init.lua" "$HOME/.config/nvim/"
fi