From 21a0093374afda51edf31e0c7b76946ddcd6ec3d Mon Sep 17 00:00:00 2001 From: "warren.veerasingam" Date: Fri, 18 Sep 2020 14:50:01 -0500 Subject: [PATCH] option to switch with fish shell --- README.md | 23 +++++++++++++++++++++ www/docs/Quick-Start.md | 45 ++++++++++++++++++++--------------------- 2 files changed, 45 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 05c8ccb2..30cb5e9f 100644 --- a/README.md +++ b/README.md @@ -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 drawing diff --git a/www/docs/Quick-Start.md b/www/docs/Quick-Start.md index de3bff20..0038bb68 100644 --- a/www/docs/Quick-Start.md +++ b/www/docs/Quick-Start.md @@ -37,29 +37,6 @@ terraform { ``` drawing -**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 @@ -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 +```