You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add the following to the end of your `~/.bashrc` file:
89
-
```
90
-
cdtfswitch(){
91
-
builtin cd "$@";
92
-
cdir=$PWD;
93
-
if [ -f "$cdir/.tfswitch.toml" ]; then
94
-
tfswitch
95
-
fi
96
-
}
97
-
alias cd='cdtfswitch'
98
-
```
99
-
100
-
**Automatically switch with zsh**
101
-
102
-
Add the following to the end of your `~/.zshrc` file:
103
-
104
-
```
105
-
load-tfswitch() {
106
-
local tfswitchrc_path=".tfswitch.toml"
107
-
108
-
if [ -f "$tfswitchrc_path" ]; then
109
-
tfswitch
110
-
fi
111
-
}
112
-
add-zsh-hook chpwd load-tfswitch
113
-
load-tfswitch
114
-
```
115
-
> NOTE: if you see an error like this: `command not found: add-zsh-hook`, then you might be on an older version of zsh (see below), or you simply need to load `add-zsh-hook` by adding this to your `.zshrc`:
1. Create a `.tfswitchrc` file containing the desired version
135
89
2. For example, `echo "0.10.5" >> .tfswitchrc` for version 0.10.5 of terraform
136
90
3. Run the command `tfswitch` in the same directory as your `.tfswitchrc`
137
91
92
+
*Instead of a `.tfswitchrc` file, a `.terraform-version` file may be used for compatibility with [`tfenv`](https://github.com/tfutils/tfenv#terraform-version-file) and other tools which use it*
138
93
139
94
**Automatically switch with bash**
140
95
141
96
Add the following to the end of your `~/.bashrc` file:
97
+
(Use either `.tfswitchrc` or `.tfswitch.toml` or `.terraform-version`)
Copy file name to clipboardExpand all lines: docs/_site/additional.html
+11-5Lines changed: 11 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@
23
23
{"description":"Manage terraform versions - the tfswitch command line tool lets you switch between different versions of terraform","@type":"WebPage","url":"/additional.html","publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"/assets/img/logo.png"}},"headline":"tfswitch","@context":"http://schema.org"}</script>
Copy file name to clipboardExpand all lines: docs/_site/index.html
+32-53Lines changed: 32 additions & 53 deletions
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@
23
23
{"name":"tfswitch","description":"Manage terraform versions - the tfswitch command line tool lets you switch between different versions of terraform","@type":"WebSite","url":"/","publisher":{"@type":"Organization","logo":{"@type":"ImageObject","url":"/assets/img/logo.png"}},"headline":"Terraform Switcher","@context":"http://schema.org"}</script>
<li><ahref="https://github.com/warrensbox/terraform-switcher/releases">Releases On <strong>GitHub</strong></a></li>
63
66
</ul>
64
67
68
+
69
+
<!-- Place this tag where you want the button to render. -->
70
+
<aclass="github-button" href="https://github.com/warrensbox/terraform-switcher" data-size="large" data-show-count="true" aria-label="Star warrensbox/terraform-switcher on GitHub">Star</a>
65
71
</header>
66
72
<section>
67
73
@@ -128,10 +134,11 @@ <h3 id="see-all-versions-including-beta-alpha-and-release-candidatesrc">See all
128
134
<li>Hit <strong>Enter</strong> to select the desired version.</li>
129
135
</ol>
130
136
131
-
<h3id="use-tfswitchtoml-file--for-uprivilege-users-non-admin---users-with-limited-privilege-on-their-computer">Use .tfswitch.toml file (For uprivilege users/ non-admin - users with limited privilege on their computer)</h3>
137
+
<h3id="use-tfswitchtoml-file--for-non-admin---users-with-limited-privilege-on-their-computers">Use .tfswitch.toml file (For non-admin - users with limited privilege on their computers)</h3>
132
138
<p>This is similiar to using a .tfswitchrc file, but you can specify a custom binary path for your terraform installation</p>
<li>Create a custom binary path. Ex: <codeclass="highlighter-rouge">mkdir /Users/warrenveerasingam/bin</code> (replace warrenveerasingam with your username)</li>
<li>Run <codeclass="highlighter-rouge">tfswitch</code> and it should automatically install the required terraform version in the specified binary path</li>
<p>NOTE: if you see an error like this: <codeclass="highlighter-rouge">command not found: add-zsh-hook</code>, then you might be on an older version of zsh (see below), or you simply need to load <codeclass="highlighter-rouge">add-zsh-hook</code> by adding this to your <codeclass="highlighter-rouge">.zshrc</code>:</p>
<li>Run the command <codeclass="highlighter-rouge">tfswitch</code> in the same directory as your <codeclass="highlighter-rouge">.tfswitchrc</code>.</li>
201
163
</ol>
202
164
165
+
<p><em>Instead of a <codeclass="highlighter-rouge">.tfswitchrc</code> file, a <codeclass="highlighter-rouge">.terraform-version</code> file may be used for compatibility with <ahref="https://github.com/tfutils/tfenv#terraform-version-file"><codeclass="highlighter-rouge">tfenv</code></a> and other tools which use it</em></p>
166
+
203
167
<p><strong>Automatically switch with bash</strong></p>
204
168
205
-
<p>Add the following to the end of your <codeclass="highlighter-rouge">~/.bashrc</code> file:</p>
169
+
<p>Add the following to the end of your <codeclass="highlighter-rouge">~/.bashrc</code> file:
170
+
(Use either <codeclass="highlighter-rouge">.tfswitchrc</code> or <codeclass="highlighter-rouge">.tfswitch.toml</code> or <codeclass="highlighter-rouge">.terraform-version</code>)</p>
0 commit comments