Skip to content

Commit

Permalink
updated readme. fix broken function
Browse files Browse the repository at this point in the history
  • Loading branch information
warrensbox committed Oct 18, 2019
1 parent 56568b1 commit 7913bfa
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 3 deletions.
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,63 @@ The most recently selected versions are presented at the top of the dropdown.
2. For example, `tgswitch 0.10.7` for version 0.10.7 of terragrunt.
3. Hit **Enter** to switch version.

### Use .tgswitchrc file
<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tgswitch/manual-tgswitchrc.gif" alt="drawing" style="width: 170px;"/>

1. Create a `.tgswitchrc` file containing the desired version
2. For example, `echo "0.14.1" >> .tgswitchrc` for version 0.10.5 of terraform
3. Run the command `tgswitch` in the same directory as your `.tgswitchrc`

**Automatically switch with bash**

Add the following to the end of your `~/.bashrc` file:
(Use `.tgswitchrc`)

```
cdtgswitch(){
builtin cd "$@";
cdir=$PWD;
if [ -f "$cdir/.tgswitchrc" ]; then
tgswitch
fi
}
alias cd='cdtgswitch'
```

<img src="https://s3.us-east-2.amazonaws.com/kepler-images/warrensbox/tgswitch/auto-tgswitchrc.gif" alt="drawing" style="width: 170px;"/>

**Automatically switch with zsh**


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

```
load-tgswitch() {
local tgswitchrc_path=".tgswitchrc"
if [ -f "$tgswitchrc_path" ]; then
tgswitch
fi
}
add-zsh-hook chpwd load-tgswitch
load-tgswitch
```
> 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`:
> ```
> autoload -U add-zsh-hook
> ```
*older version of zsh*
```
cd(){
builtin cd "$@";
cdir=$PWD;
if [ -f "$cdir/.tgswitchrc" ]; then
tgswitch
fi
}
```
## Additional Info
See how to *upgrade*, *uninstall*, *troubleshoot* here:[More info](https://warrensbox.github.io/tgswitch/additional)
Expand Down
6 changes: 3 additions & 3 deletions lib/symlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func CreateSymlink(cwd string, dir string) {
Try running "unlink" to remove existing symlink.
If error persist, you may not have the permission to create a symlink at %s.
Error: %s
`, dir, dir, err)
`, dir, err)
os.Exit(1)
}
}
Expand All @@ -33,7 +33,7 @@ func RemoveSymlink(symlinkPath string) {
Try running "unlink" to remove existing symlink.
If error persist, you may not have the permission to create a symlink at %s.
Error: %s
`, symlinkPath, symlinkPath, err)
`, symlinkPath, err)
os.Exit(1)
} else {
errRemove := os.Remove(symlinkPath)
Expand All @@ -44,7 +44,7 @@ func RemoveSymlink(symlinkPath string) {
Try running "unlink" to remove existing symlink.
If error persist, you may not have the permission to create a symlink at %s.
Error: %s
`, symlinkPath, symlinkPath, errRemove)
`, symlinkPath, errRemove)
os.Exit(1)
}
}
Expand Down

0 comments on commit 7913bfa

Please sign in to comment.