Skip to content

Instantly share code, notes, and snippets.

@Taytay
Created June 26, 2018 19:12
Show Gist options
  • Save Taytay/4b463d3e7ebf9915107251b3abad7073 to your computer and use it in GitHub Desktop.
Save Taytay/4b463d3e7ebf9915107251b3abad7073 to your computer and use it in GitHub Desktop.
Install latest version of Github's hub on Linux
#!/bin/bash
# Installs latest release of hub on Linux
# Echo, halt on errors, halt on uninitialized ENV variables. (https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/)
set -euxo pipefail
# Hub doesn't have a way to install the latest version using `apt` yet, so I wrote this as a hacky substitute.
# This will be unnecessary when this issue is resolved: https://github.com/github/hub/issues/718#issuecomment-65824284
# Linux options include:
# freebsd-386
# freebsd-amd64
# linux-386
# linux-amd64
# linux-arm
# linux-arm64
# Others: darwin-amd64, windows-386, windows-amd64
HUB_DIST=linux-amd64
HUB_VERSION=`curl -w "%{url_effective}\n" -I -L -s -S github.com/github/hub/releases/latest -o /dev/null | awk -F'releases/tag/v' '{ print $2 }'`
curl "https://github.com/github/hub/releases/download/v$HUB_VERSION/hub-$HUB_DIST-$HUB_VERSION.tgz" -L | tar xvz
sudo ./hub-$HUB_DIST-$HUB_VERSION/install
rm -r ./hub-$HUB_DIST-$HUB_VERSION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment