Skip to content

Instantly share code, notes, and snippets.

@tracphil
Created January 28, 2020 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tracphil/4c847319ccdabeca81337bbc97d66be5 to your computer and use it in GitHub Desktop.
Save tracphil/4c847319ccdabeca81337bbc97d66be5 to your computer and use it in GitHub Desktop.
Install Terraform with tfswitch

tfswitch

Install tfswitch

brew install warrensbox/tap/tfswitch

Install terraform

tfswitch

Select the version of terraform that you want to install.

Change terraform version

Use tfswitch for different versions of terraform when cd'ing into a project directory.

cd ~/Projects/terraform/azure
echo "0.12.19" >> .tfswitchrc

Add the following to your zsh configuration

load-tfswitch() {
  local tfswitchrc_path=".tfswitchrc"

  if [ -f "$tfswitchrc_path" ]; then
    tfswitch
  fi
}
add-zsh-hook chpwd load-tfswitch
load-tfswitch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment