Files
asciinema/install

63 lines
1.9 KiB
Plaintext
Raw Normal View History

2014-12-16 12:07:58 +01:00
#!/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
2014-12-17 17:10:03 +01:00
Linux.x86_64) platform=linux-amd64;;
Linux.i?86) platform=linux-386;;
2014-12-22 22:37:07 +01:00
Linux.armv6l) platform=linux-arm;;
Linux.armv7l) platform=linux-arm;;
2015-06-26 10:12:05 -04:00
FreeBSD.amd64) platform=freebsd-amd64;;
FreeBSD.i386) platform=freebsd-386;;
2014-12-17 17:10:03 +01:00
Darwin.x86_64) platform=darwin-amd64;;
Darwin.i?86) platform=darwin-386;;
2014-12-16 12:07:58 +01:00
*) echo "Sorry, there is no asciinema binary available for your platform. Try building from source." >&2; exit 1;;
esac
2015-06-21 18:05:54 +02:00
version=1.1.1
2015-03-05 15:57:12 +01:00
url="https://github.com/asciinema/asciinema/releases/download/v${version}/asciinema-${version}-${platform}.tar.gz"
2014-12-16 12:07:58 +01:00
bin_name="asciinema"
sudo=""
tmpdir=$(mktemp -d 2>/dev/null || mktemp -d -t 'asciinema-tmp')
2014-12-16 12:07:58 +01:00
trap 'rm -rf $tmpdir' EXIT
2014-12-17 17:10:03 +01:00
echo "Downloading asciinema v${version} for $platform..."
2014-12-16 12:07:58 +01:00
curl -L --progress-bar "$url" | tar xz -C $tmpdir
2014-12-17 17:55:21 +01:00
if [ -d "$HOME/bin" ]; then
if echo ":$PATH:" | grep -q ":~/bin:" || echo ":$PATH:" | grep -q ":$HOME/bin:"; then
target="$HOME/bin/$bin_name"
2014-12-16 12:07:58 +01:00
fi
2014-12-17 17:55:21 +01:00
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
2014-12-16 12:07:58 +01:00
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
2014-12-16 12:07:58 +01:00
$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