Skip to content

Instantly share code, notes, and snippets.

@anakaiti
Created March 10, 2020 09:18
Show Gist options
  • Save anakaiti/632f5c71f5643103f20a6531508f84c7 to your computer and use it in GitHub Desktop.
Save anakaiti/632f5c71f5643103f20a6531508f84c7 to your computer and use it in GitHub Desktop.
Terraform update script for fish shell
function update-terraform --description 'Updates terraform to the latest version'
set -l base 'https://releases.hashicorp.com/terraform'
set -l ver (curl -s $base/ | grep '<a href="/terraform/' | head -n1 | cut -d'/' -f 3)
set -l tmpdir (mktemp -d)
wget -O $tmpdir/tf.zip $base/$ver/terraform_"$ver"_linux_amd64.zip
unzip $tmpdir/tf.zip -d $tmpdir
install $tmpdir/terraform (which terraform)
terraform version
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment