Skip to content

Instantly share code, notes, and snippets.

@tobynet
Created July 10, 2014 06:43
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobynet/eab44788828dd01c487c to your computer and use it in GitHub Desktop.
Save tobynet/eab44788828dd01c487c to your computer and use it in GitHub Desktop.
Install latest peco binary for Linux amd64 from https://github.com/peco/peco/releases/latest
#!/usr/bin/env bash
# Usage: BINDIR=$HOME/bin/ bash install-peco.sh
set -o xtrace # for debug output. ( abbr. set -x )
set -o errexit # for exit on error. ( abbr. set -e )
set -o pipefail # errexit for pipe
set -o nounset # exit when the script to use undeclared variables (abbr. set -u)
filename=peco_linux_amd64.tar.gz
latest_tag="$(curl -L --head https://github.com/peco/peco/releases/latest | grep -i location: | sed 's/^.*\/tag\/\([^\/]*\)\r$/\1/')"
uri_to_download="https://github.com/peco/peco/releases/download/${latest_tag}/${filename}"
bindir="${BINDIR:-"$HOME/bin/"}"
pushd "$(mktemp -d "/tmp/tmp.XXXXXXXXXX")"
curl -O -L "$uri_to_download"
tar xf "$filename"
cp "${filename%%.*}/peco" "$bindir"
popd
if [[ ! -x "${bindir}/peco" ]]; then
echo '"peco" was not successfully installed!' >&2
exit 2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment