Skip to content

Commit

Permalink
option to switch with fish shell
Browse files Browse the repository at this point in the history
  • Loading branch information
warrensbox committed Sep 18, 2020
1 parent 37f3bda commit 21a0093
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 23 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,29 @@ cd(){
}
```

**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
```
### Jenkins setup
<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tfswitch/jenkins_tfswitch.png" alt="drawing" style="width: 170px;"/>
Expand Down
45 changes: 22 additions & 23 deletions www/docs/Quick-Start.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,6 @@ 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 @@ -132,3 +109,25 @@ cd(){
fi
}
```
**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
```

0 comments on commit 21a0093

Please sign in to comment.