{"id":23696883,"url":"https://github.com/yleisradio/chtf","last_synced_at":"2025-09-03T00:32:09.693Z","repository":{"id":42986056,"uuid":"307939696","full_name":"Yleisradio/chtf","owner":"Yleisradio","description":"Terraform version switcher with automatic install","archived":false,"fork":false,"pushed_at":"2024-03-17T20:48:55.000Z","size":84,"stargazers_count":20,"open_issues_count":3,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-15T00:05:19.765Z","etag":null,"topics":["bash","fish","installer","linux","macos","manage","shell","terraform","terraform-versions","versions","zsh"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Yleisradio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-28T07:36:33.000Z","updated_at":"2023-05-12T17:01:10.000Z","dependencies_parsed_at":"2022-07-22T12:32:39.531Z","dependency_job_id":null,"html_url":"https://github.com/Yleisradio/chtf","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yleisradio%2Fchtf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yleisradio%2Fchtf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yleisradio%2Fchtf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yleisradio%2Fchtf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yleisradio","download_url":"https://codeload.github.com/Yleisradio/chtf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231819091,"owners_count":18431243,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","fish","installer","linux","macos","manage","shell","terraform","terraform-versions","versions","zsh"],"created_at":"2024-12-30T06:17:40.072Z","updated_at":"2024-12-30T06:17:40.590Z","avatar_url":"https://github.com/Yleisradio.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chtf - Terraform version switcher\n\nDo you need different Terraform versions on different projects? Or maybe you want to test your modules with a new Terraform version?\n\n`chtf` is a small shell tool for selecting a specified [Terraform](https://www.terraform.io/) version. It can also install the specified version automatically.\n\n---\n\n## Requirements\n\n`chtf` supports currently [bash](http://www.gnu.org/software/bash/), [zsh](http://zsh.sourceforge.net/), and [fish](https://fishshell.com/) shells. Version switching itself doesn't have any external dependencies.\n\nOptional automatic install of missing Terraform versions requires either:\n\n- [Homebrew](https://brew.sh/) with [yleisradio/terraforms](https://github.com/Yleisradio/homebrew-terraforms) Tap (see below)\n- bash, unzip, and wget or curl\n\n---\n\n## Installation\n\n### Homebrew\n\nOn MacOS (and OSX) the easiest way is to use Homebrew. After installing Homebrew, run:\n\n    brew install yleisradio/terraforms/chtf\n\nHomebrew also installs the completion for all supported shells.\n\n### All systems\n\nManual installation on all systems:\n\n    curl -L -o chtf-2.2.2.tar.gz https://github.com/Yleisradio/chtf/archive/v2.2.2.tar.gz\n    tar -xzvf chtf-2.2.2.tar.gz\n    cd chtf-2.2.2/\n    make install\n\nThe default installation location is `$HOME/share/chtf/` for bash/zsh, and `$HOME/.config/fish/` for fish. See the [Tips section](#tips) for installing to other locations.\n\nThe `etc/` directory includes completion files for the supported shells. Follow your shell's instructions how to install them. The fish autocompletion is installed for autoloading.\n\n---\n\n## Configuration\n\nThe following environment variables can be used for configuring `chtf`. Click to expand.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ccode\u003eCHTF_TERRAFORM_DIR\u003c/code\u003e\u003c/strong\u003e - Specifies where the Terraform versions are stored.\u003c/summary\u003e\n\nDefaults to the Homebrew Caskroom if the \"yleisradio/terraforms\" Tap is installed, `$HOME/.terraforms/` otherwise.\nEach version should be installed as `$CHTF_TERRAFORM_DIR/terraform-\u003cversion\u003e/terraform`.\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ccode\u003eCHTF_AUTO_INSTALL\u003c/code\u003e\u003c/strong\u003e - Controls automatic installation missing Terraform versions.\u003c/summary\u003e\n\nPossible values are: `yes`, `no`, and `ask`.\nThe default is `ask`, which will prompt the user for confirmation before automatic installation.\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ccode\u003eCHTF_AUTO_INSTALL_METHOD\u003c/code\u003e\u003c/strong\u003e - Specifies the method used for automatic installation.\u003c/summary\u003e\n\nThe default is `homebrew` if `CHTF_TERRAFORM_DIR` is no specified and the \"yleisradio/terraforms\" Tap is installed, `zip`  otherwise.\nThere shouldn't be normally need to set this variable.\n\n\u003c/details\u003e\n\n### Activating the `chtf` command\n\nAfter installing, `chtf` has to be loaded to the shell.\n\n#### fish\n\nThe fish version is [autoloaded](https://fishshell.com/docs/current/tutorial.html#autoloading-functions) so there is nothing more to do!\n\n#### bash and zsh\n\nThe base directory on the following examples depends how and where `chtf` is installed. This assumes `make install`. With Homebrew, replace `$HOME` with the output of `brew --prefix`.\n\nNew shell session has to be started for the changes to take effect.\n\nAdd the following to the `~/.bashrc` or `~/.zshrc`:\n\n```bash\n######################################################################\n# chtf\n\n# Uncomment and change the value to override the default:\n#CHTF_AUTO_INSTALL=\"ask\" # yes/no/ask\n\nif [[ -f \"$HOME/share/chtf/chtf.sh\" ]]; then\n    source \"$HOME/share/chtf/chtf.sh\"\nfi\n```\n\n## Usage\n\nList all installed Terraform versions:\n\n    chtf\n\nSelect the wanted Terraform version, for example:\n\n    chtf 0.13.5\n\nUse the Terraform version installed globally outside `chtf` (e.g. via a package manager):\n\n    chtf system\n\n### Tips\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eCustomized install\u003c/strong\u003e\u003c/summary\u003e\n\n`make install` installs `chtf` by default to the user's `$HOME` directory. But if installed as a root user (e.g. via `sudo`), the default location is `/usr/local` for system wide use. In both cases the wanted location can be specified with `PREFIX`. For example:\n\n    sudo make install PREFIX=/opt\n\nThe development version of `chtf` can be used either by `source`ing or `make install`ing from a [clone of this repository](https://docs.github.com/en/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/cloning-a-repository), or with Homebrew:\n\n    brew install yleisradio/terraforms/chtf --HEAD\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eAutomatic switching on new shell session\u003c/strong\u003e\u003c/summary\u003e\n\nIf you want to have a default Terraform version selected when starting a new shell session, you can of course add `chtf \u003cversion\u003e` to the config file after loading `chtf`.\nA bit more flexible way is to write the wanted version number to a file named `~/.terraform-version`, and read that.\n\n```bash\n# bash and zsh\nif [[ -f \"$HOME/.terraform-version\" ]]; then\n    chtf \"$(\u003c \"$HOME/.terraform-version\")\"\nfi\n```\n\n```fish\n# fish\nif test -f $HOME/.terraform-version\n    chtf (cat $HOME/.terraform-version)\nend\n```\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eUninstalling Terraform versions\u003c/strong\u003e\u003c/summary\u003e\n\nHomebrew installed Terraform versions can be uninstalled with:\n\n    brew uninstall --cask terraform-\u003cversion\u003e\n\nNote that the `\u003cversion\u003e` uses dashes instead of dots for versions installed with `chtf` v2.2.0 and newer.\n\nOtherwise installed versions can be uninstalled by deleting the directory:\n\n    rm -r \"$CHTF_TERRAFORM_DIR/terraform-\u003cversion\u003e\"\n\n\u003c/details\u003e\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eUninstalling chtf\u003c/strong\u003e\u003c/summary\u003e\n\nHomebrew installed `chtf` can be uninstalled with:\n\n    brew uninstall chtf\n\n`chtf` installed with `make` can be uninstalled by deleting the directory:\n\n    rm -r \"$HOME/share/chtf\" # or where it was installed\n\n\u003c/details\u003e\n\n---\n\n## Contributing\n\nBug reports, pull requests, and other contributions are welcome on GitHub at [https://github.com/Yleisradio/chtf](https://github.com/Yleisradio/chtf).\n\nThis project is intended to be a safe, welcoming space for collaboration. By participating in this project you agree to abide by the terms of [Contributor Code of Conduct](CODE_OF_CONDUCT.md).\n\n---\n\n## Licence and Credits\n\nThe project is released as open source under the terms of the [MIT License](LICENSE).\n\nOriginal idea and implementation of `chtf` was heavily affected by [chruby](https://github.com/postmodern/chruby).\n\nIncluded [terraform-installer](https://github.com/robertpeteuil/terraform-installer) is released under the [Apache 2.0 License](https://github.com/robertpeteuil/terraform-installer/blob/1.5.4/LICENSE).\n\n_NOTE: `chtf` was originally part of the [homebrew-terraforms](https://github.com/Yleisradio/homebrew-terraforms/) project, but has been extracted to own project and modified to support also non-Homebrew environments._\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyleisradio%2Fchtf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyleisradio%2Fchtf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyleisradio%2Fchtf/lists"}