-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·42 lines (33 loc) · 1.03 KB
/
install.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
#!/bin/bash
# Check if wget or curl is installed
downloader=""
if command -v wget &> /dev/null; then
downloader="wget -O"
elif command -v curl &> /dev/null; then
downloader="curl -o"
else
echo "Neither curl nor wget is installed. Please install either curl or wget."
exit 1
fi
# Create a temporary directory and file
temp_dir=$(mktemp -d)
temp_file="$temp_dir/lg.sh"
# Download the source file
$downloader "$temp_file" "https://raw.githubusercontent.com/siwymilek/lg-sh/main/lg.sh"
# Check if the download was successful
if [ $? -ne 0 ]; then
echo "Failed to download the file."
exit 1
fi
# Make the downloaded file executable
chmod +x "$temp_file"
# Move the file to /usr/local/bin/ and ensure sudo is used only if necessary
install_location="/usr/local/bin/lg"
if [ ! -w "$(dirname $install_location)" ]; then
sudo mv "$temp_file" "$install_location"
else
mv "$temp_file" "$install_location"
fi
echo "lazygit script installed successfully at $install_location"
# Clean up the temporary directory
rm -rf "$temp_dir"