-
Notifications
You must be signed in to change notification settings - Fork 62
/
tmux-thumbs-install.sh
executable file
·118 lines (82 loc) · 4.35 KB
/
tmux-thumbs-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
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
#!/usr/bin/env bash
set -Eeu -o pipefail
# Removing the binary to make this script idempotent
rm -rf target/release/thumbs
clear
cat << EOF
█████ █████ █████ █████
░░███ ░░███ ░░███ ░░███
███████ █████████████ █████ ████ █████ █████ ███████ ░███████ █████ ████ █████████████ ░███████ █████
░░░███░ ░░███░░███░░███ ░░███ ░███ ░░███ ░░███ ██████████░░░███░ ░███░░███ ░░███ ░███ ░░███░░███░░███ ░███░░███ ███░░
░███ ░███ ░███ ░███ ░███ ░███ ░░░█████░ ░░░░░░░░░░ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███░░█████
░███ ███ ░███ ░███ ░███ ░███ ░███ ███░░░███ ░███ ███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░███ ░░░░███
░░█████ █████░███ █████ ░░████████ █████ █████ ░░█████ ████ █████ ░░████████ █████░███ █████ ████████ ██████
░░░░░ ░░░░░ ░░░ ░░░░░ ░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░ ░░░░░ ░░░░░░░░ ░░░░░ ░░░ ░░░░░ ░░░░░░░░ ░░░░░░
EOF
if [ "${1:-install}" == "update" ]; then
cat << EOF
⚠️ UPDATE! ⚠️
It looks like you got a new version of tmux-thumbs repository but
the binary version is not in sync.
We are going to proceed with the new installation.
Do you want to continue?
Press any key to continue...
EOF
else
cat << EOF
It looks like this is the first time you are executing tmux-thumbs
because the binary is not present. We are going to proceed with the
installation.
Do you want to continue?
Press any key to continue...
EOF
fi
read -rs -n 1
cat << EOF
Which format do you prefer for installation?
1) Compile: will use cargo to compile tmux-thumbs. It requires Rust.
2) Download: will download a precompiled binary for your system.
EOF
select opt in "Compile" "Download"; do
case $opt in
Compile|1)
if ! [ -x "$(command -v cargo)" ]; then
echo '❌ Rust is not installed!'
exit 1
fi
echo ' Compiling tmux-thumbs, be patient:'
cargo build --release --target-dir=target
break;;
Download|2)
platform="$(uname -s)_$(uname -m)"
echo " Downloading ${platform} binary..."
sources=$(curl -s "https://api.github.com/repos/fcsonline/tmux-thumbs/releases/latest" | grep browser_download_url)
case $platform in
Darwin_x86_64)
url=$(echo "${sources}" | grep -o 'https://.*darwin.zip' | uniq)
curl -sL "${url}" | bsdtar -xf - thumbs tmux-thumbs
;;
Linux_x86_64)
url=$(echo "${sources}" | grep -o 'https://.*linux-musl.tar.gz' | uniq)
curl -sL "${url}" | tar -zxf - thumbs tmux-thumbs
;;
*)
echo "❌ Unknown platform: ${platform}"
read -rs -n 1
echo " Press any key to close this pane..."
exit 1
;;
esac
chmod +x thumbs tmux-thumbs
mkdir -p target/release
mv thumbs tmux-thumbs target/release
break;;
*)
echo "❌ Ouh? Choose an available option."
esac
done
cat << EOF
Installation complete! 💯
Press any key to close this pane...
EOF
read -rs -n 1