-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlazygit-installer
More file actions
executable file
·48 lines (35 loc) · 1.14 KB
/
lazygit-installer
File metadata and controls
executable file
·48 lines (35 loc) · 1.14 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
#!/bin/sh
myname=${0##*/}
TMPDIR="${TMPDIR:-/tmp}"
cache_dir="$TMPDIR/lazygit_installer_$$"
die() {
[ -n "$1" ] && printf '%s\n' "$*" >&2;
exit 1
}
cleanup() {
rm -rf -- "$cache_dir"
}
trap cleanup EXIT INT TERM
echo "-- ${myname} --"
echo "${myname}: fetching lazygit version"
LAZYGIT_VERSION=$(
curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" \
| grep -Po '"tag_name": "v\K[^"]*'
)
echo "${myname}: will install lazygit version ${LAZYGIT_VERSION}"
echo "${myname}: downloading..."
archive="lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz"
url="https://github.com/jesseduffield/lazygit/releases/latest/download/${archive}"
[ -d "$cache_dir" ] || mkdir -p -- "$cache_dir" || die "unable to create cache dir at ${cache_dir}"
cd "$cache_dir" || die "could not cd to cache dir!"
curl -Lo lazygit.tar.gz "${url}" || die "download failed!"
echo "${myname}: installing..."
tar xf lazygit.tar.gz lazygit || die "extraction failed!"
# got root?
if [ "$(id -u)" -eq 0 ]; then
install lazygit /usr/local/bin/
else
sudo install lazygit /usr/local/bin/
fi
echo "${myname}: installation complete!"
cd || die