-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstallGarudaNvim.sh
executable file
·321 lines (297 loc) · 11.3 KB
/
installGarudaNvim.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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
#!/usr/bin/env sh
#
# GarudaNvim installer for macOS.
# Welcome message
echo
echo
echo "Welcome to GarudaNvim!"
echo ""
echo "The installer supports Operating Systems like:"
echo "MacOS, Arch, Fedora, CentOS, RHEL, Ubuntu and Debian"
echo "And all their distributions!"
echo
echo "=================================================================================================================="
echo
# Step 1: Detect OS
echo "Step 1: Detecting Operating System"
echo "------------------------------------------------------------------------------------------------------------------"
OS=""
if [ "$(uname)" = "Darwin" ]; then
OS="macOS"
elif [ -f /etc/os-release ]; then
. /etc/os-release
case "$ID" in
ubuntu|debian)
OS="Ubuntu"
;;
arch)
OS="Arch"
;;
fedora)
OS="Fedora"
;;
centos|rhel)
OS="RHEL"
;;
*)
OS="Unsupported"
;;
esac
else
OS="Unsupported"
fi
if [ "$OS" = "Unsupported" ]; then
echo "ERROR: Your operating system is not supported by this installer."
echo "Supported OS: macOS, Arch, Ubuntu, Debian, Fedora, CentOS, RHEL. And their distributions."
echo
echo
exit 1
fi
echo "INFO: Detected OS - $OS"
# Ensure the ~/.config/ directory exists
if [ ! -d ~/.config ]; then
echo "INFO: ~/.config/ directory not found. Creating it..."
mkdir -p ~/.config
fi
echo "INFO: System checks passed! Continuing with installation."
echo
echo
# Step 2: Check if Neovim is installed
echo "Step 2: Checking if Neovim is already installed"
echo "------------------------------------------------------------------------------------------------------------------"
if command -v nvim >/dev/null 2>&1; then
echo "INFO: Neovim is already installed on your system!"
else
echo "INFO: Neovim is not installed. Installing Neovim for $OS..."
case "$OS" in
macOS)
if ! command -v brew >/dev/null 2>&1; then
echo "ERROR: Homebrew is not installed. Please install Homebrew to proceed."
echo "Visit https://brew.sh/ for instructions."
echo
echo
exit 1
fi
brew install neovim
;;
Ubuntu)
sudo apt update
sudo apt install -y neovim
;;
Arch)
sudo pacman -Sy neovim
;;
Fedora)
sudo dnf install -y neovim
;;
RHEL)
sudo yum install -y neovim
;;
esac
if command -v nvim >/dev/null 2>&1; then
echo
echo "INFO: Neovim has been successfully installed!"
else
echo "ERROR: Failed to install Neovim. Please try installing it manually."
echo
echo
exit 1
fi
fi
echo
echo
# Step 3: Checking for System Dependencies
echo "Step 3: Checking for GarudaNvim Dependencies"
echo "------------------------------------------------------------------------------------------------------------------"
echo "Checking for the following dependencies on your system:"
echo "Node, Python, Ripgrep, Lazygit, Htop, Hack Nerd Font"
echo "Though these are not strictly required, having them provides a seamless GarudaNvim experience."
echo
dependencies=("node" "python3" "rg" "lazygit" "htop")
installed_dependencies=()
missing_dependencies=()
for dep in "${dependencies[@]}"; do
if command -v "$dep" >/dev/null 2>&1; then
installed_dependencies+=("$dep")
else
missing_dependencies+=("$dep")
fi
done
# Display information on installed and missing dependencies
if [ ${#missing_dependencies[@]} -eq 0 ]; then
echo "INFO: All essential dependencies are already installed."
else
echo "INFO: Found installed dependencies: ${installed_dependencies[*]}"
echo "INFO: Missing dependencies: ${missing_dependencies[*]}"
# Prompt to install missing dependencies
for dep in "${missing_dependencies[@]}"; do
echo
read -p "Would you like to install $dep? (y/n): " install_choice
if [ "$install_choice" = "y" ]; then
case "$OS" in
macOS)
if [ "$dep" = "node" ]; then brew install node; fi
if [ "$dep" = "python3" ]; then brew install python; fi
if [ "$dep" = "rg" ]; then brew install ripgrep; fi
if [ "$dep" = "lazygit" ]; then brew install lazygit; fi
if [ "$dep" = "htop" ]; then brew install htop; fi
;;
Ubuntu)
sudo apt update
if [ "$dep" = "node" ]; then sudo apt install -y nodejs; fi
if [ "$dep" = "python3" ]; then sudo apt install -y python3; fi
if [ "$dep" = "rg" ]; then sudo apt install -y ripgrep; fi
if [ "$dep" = "lazygit" ]; then sudo add-apt-repository ppa:lazygit-team/release && sudo apt install -y lazygit; fi
if [ "$dep" = "htop" ]; then sudo apt install -y htop; fi
;;
Arch)
if [ "$dep" = "node" ]; then sudo pacman -Sy nodejs; fi
if [ "$dep" = "python3" ]; then sudo pacman -Sy python; fi
if [ "$dep" = "rg" ]; then sudo pacman -Sy ripgrep; fi
if [ "$dep" = "lazygit" ]; then sudo pacman -Sy lazygit; fi
if [ "$dep" = "htop" ]; then sudo pacman -Sy htop; fi
;;
Fedora)
if [ "$dep" = "node" ]; then sudo dnf install -y nodejs; fi
if [ "$dep" = "python3" ]; then sudo dnf install -y python3; fi
if [ "$dep" = "rg" ]; then sudo dnf install -y ripgrep; fi
if [ "$dep" = "lazygit" ]; then sudo dnf install -y lazygit; fi
if [ "$dep" = "htop" ]; then sudo dnf install -y htop; fi
;;
RHEL)
if [ "$dep" = "node" ]; then sudo yum install -y nodejs; fi
if [ "$dep" = "python3" ]; then sudo yum install -y python3; fi
if [ "$dep" = "rg" ]; then sudo yum install -y ripgrep; fi
if [ "$dep" = "lazygit" ]; then sudo yum install -y lazygit; fi
if [ "$dep" = "htop" ]; then sudo yum install -y htop; fi
;;
esac
if command -v "$dep" >/dev/null 2>&1; then
echo
echo "INFO: $dep has been successfully installed!"
else
echo "WARNING: Failed to install $dep. Please install it manually if you want GarudaNvim to function smoothly."
fi
else
echo "Please install $dep manually if you want GarudaNvim to function smoothly."
fi
done
fi
# Check and install Hack Nerd Font
echo
echo "Checking for Hack Nerd Font..."
FONT_NAME="Hack Nerd Font"
if [ "$OS" = "macOS" ]; then
FONT_DIR="$HOME/Library/Fonts"
else
FONT_DIR="$HOME/.local/share/fonts"
fi
FONT_PATH="$FONT_DIR/HackNerdFont-Regular.ttf"
if [ -f "$FONT_PATH" ]; then
echo "INFO: $FONT_NAME is already installed."
else
echo "$FONT_NAME is not installed on your system."
echo "It is recommended for GarudaNvim to display icons correctly and enhance readability."
echo
read -p "Would you like to install $FONT_NAME? (y/n): " install_font_choice
if [ "$install_font_choice" = "y" ]; then
echo
echo "INFO: Installing $FONT_NAME..."
# Ensure the font directory exists
mkdir -p "$FONT_DIR"
# Download Hack Nerd Font
curl -fLo "$FONT_DIR/Hack.zip" https://github.com/ryanoasis/nerd-fonts/releases/latest/download/Hack.zip
# Unzip and install the font
unzip -o "$FONT_DIR/Hack.zip" -d "$FONT_DIR"
rm "$FONT_DIR/Hack.zip"
# Refresh the font cache for Linux
if [ "$OS" != "macOS" ]; then
if command -v fc-cache >/dev/null 2>&1; then
fc-cache -f -v
fi
fi
echo
echo "INFO: $FONT_NAME has been successfully installed!"
else
echo
echo "INFO: You chose not to install $FONT_NAME."
echo "GarudaNvim may not display icons correctly without it."
fi
fi
echo
echo
# Step 4: Check for existing Neovim configuration
echo "Step 4: Checking for existing Neovim configuration in ~/.config/nvim"
echo "------------------------------------------------------------------------------------------------------------------"
if [ -d ~/.config/nvim ]; then
echo "WARNING: The directory ~/.config/nvim already exists."
echo " You have two options:"
echo " 1. Delete your current Neovim configuration and install GarudaNvim."
echo " 2. Backup your current Neovim configuration before installing GarudaNvim."
echo
read -p "Would you like to delete the existing configuration? (y/n): " delete_choice
if [ "$delete_choice" = "y" ]; then
echo "INFO: Deleting existing Neovim configuration..."
# Deleting current configuration
rm -rf ~/.config/nvim
rm -rf ~/.local/share/nvim
rm -rf ~/.local/state/nvim
rm -rf ~/.cache/nvim
echo "INFO: Existing configuration deleted."
else
echo
echo "Step 4.5: Backup Options"
echo "------------------------------------------------------------------------------------------------------------------"
echo "You can either automatically backup your current Neovim configuration or manually do it."
read -p "Would you like to automatically backup and proceed with the installation? (y/n): " backup_choice
if [ "$backup_choice" = "y" ]; then
echo "INFO: Backing up current Neovim configuration..."
# Automatically backup the current configuration
mv ~/.config/nvim{,.bak}
# Optional but recommended backups
mv ~/.local/share/nvim{,.bak}
mv ~/.local/state/nvim{,.bak}
mv ~/.cache/nvim{,.bak}
echo "INFO: Backup complete!"
else
echo
echo "INFO: Please manually backup your configuration and try installing GarudaNvim again."
echo
echo
exit 1
fi
fi
else
echo "INFO: No existing Neovim configuration found. Continuing with installation."
fi
echo
echo
# Step 5: Cloning GarudaNvim repository
echo "Step 5: Installing GarudaNvim to ~/.config/nvim"
echo "------------------------------------------------------------------------------------------------------------------"
# Clone the repository
git clone https://github.com/garudanvim/GarudaNvim.git ~/.config/nvim
cd ~/.config/nvim || exit 1
echo "Cloned the Repository."
# Fetch the latest release tag
latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1))
# Reset to the commit of the latest release
git reset --hard "$latest_tag"
echo "Set GarudaNvim to the latest release"
echo
echo "=================================================================================================================="
echo
# Success message and opening GarudaNvim
echo "SUCCESS: Hurray! GarudaNvim has been correctly installed!"
echo "Type \"nvim\" in your terminal to start GarudaNvim"
echo
echo "NOTE: The first time you open GarudaNvim, it may take an additional 5-10 seconds to load."
echo "During this time, GarudaNvim is setting up and downloading essential plugins for your environment."
echo "Once the setup is complete, press 'q' to exit the lazy installation mode."
echo
echo "After exiting, please reopen GarudaNvim to start using it."
echo "You’ll then be ready to enjoy GarudaNvim at full capacity with all configurations and plugins installed"
echo
echo "Happy Coding with GarudaNvim! 💻"
echo
echo