forked from asciinema/asciinema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·62 lines (51 loc) · 1.94 KB
/
install
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
#!/bin/sh
# This script installs asciinema cli on your system by downloading a binary
# compatible with your platform and putting it in your $PATH.
{ # Prevent execution if this script was only partially downloaded
set -e
case "$(uname -s).$(uname -m)" in
Linux.x86_64) platform=linux-amd64;;
Linux.i?86) platform=linux-386;;
Linux.armv6l) platform=linux-arm;;
Linux.armv7l) platform=linux-arm;;
FreeBSD.amd64) platform=freebsd-amd64;;
FreeBSD.i386) platform=freebsd-386;;
Darwin.x86_64) platform=darwin-amd64;;
Darwin.i?86) platform=darwin-386;;
*) echo "Sorry, there is no asciinema binary available for your platform. Try building from source." >&2; exit 1;;
esac
version=1.2.0
url="https://github.com/asciinema/asciinema/releases/download/v${version}/asciinema-${version}-${platform}.tar.gz"
bin_name="asciinema"
sudo=""
tmpdir=$(mktemp -d 2>/dev/null || mktemp -d -t 'asciinema-tmp')
trap 'rm -rf $tmpdir' EXIT
echo "Downloading asciinema v${version} for $platform..."
curl -L --progress-bar "$url" | tar xz -C $tmpdir
if [ -d "$HOME/bin" ]; then
if echo ":$PATH:" | grep -q ":~/bin:" || echo ":$PATH:" | grep -q ":$HOME/bin:"; then
target="$HOME/bin/$bin_name"
fi
elif [ -d "/usr/local/bin" ]; then
if echo ":$PATH:" | grep -q ":/usr/local/bin:"; then
target="/usr/local/bin/$bin_name"
if [ ! -w /usr/local/bin ]; then
sudo=sudo
echo "Warning: you may be asked for administrator password to save the file in /usr/local/bin directory"
fi
fi
fi
if [ -z "$target" ]; then
target="$PWD/$bin_name"
echo "Warning: couldn't find ~/bin or /usr/local/bin in your \$PATH"
fi
echo "Installing to $target..."
if $sudo cp $tmpdir/asciinema*/asciinema $target; then
$sudo chmod a+x $target
echo "Success."
echo
echo "Start recording your terminal by running: asciinema rec"
else
echo "Error: couldn't copy $bin_name to $target"
fi
} # End of wrapping