Skip to content

Commit

Permalink
Merge pull request #100 from timkrueger/patch-1
Browse files Browse the repository at this point in the history
Execute tfswitch after cd in fish shell
  • Loading branch information
warrensbox committed Sep 18, 2020
2 parents bba738d + aca0033 commit 37f3bda
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion www/docs/Quick-Start.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,28 @@ terraform {
```
<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tfswitch/versiontf.gif" alt="drawing" style="width: 600px;"/>

**Automatically switch with fish shell**

Add the following to the end of your `~/.config/fish/config.fish` file:

```sh
function switch_terraform --on-event fish_postexec
string match --regex '^cd\s' "$argv" > /dev/null
set --local is_command_cd $status

if test $is_command_cd -eq 0
if count *.tf > /dev/null

grep -c "required_version" *.tf > /dev/null
set --local tf_contains_version $status

if test $tf_contains_version -eq 0
command tfswitch
end
end
end
end
```
### Use .tfswitch.toml file (For non-admin - users with limited privilege on their computers)
This is similiar to using a .tfswitchrc file, but you can specify a custom binary path for your terraform installation
Expand Down Expand Up @@ -109,4 +131,4 @@ cd(){
tfswitch
fi
}
```
```

0 comments on commit 37f3bda

Please sign in to comment.