Skip to content

Commit

Permalink
Alternative plain bash instructions for zsh hook
Browse files Browse the repository at this point in the history
  • Loading branch information
benwiley4000 committed Jun 29, 2017
1 parent 3ac49e5 commit 1e2643a
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,9 @@ You can use [`avn`](https://github.com/wbyoung/avn) to deeply integrate into you

If you prefer a lighter-weight solution, the recipes below have been contributed by `nvm` users. They are **not** supported by the `nvm` development team. We are, however, accepting pull requests for more examples.

#### zsh
#### Calling `nvm use` automatically in a directory with a `.nvmrc` file

##### Calling `nvm use` automatically in a directory with a `.nvmrc` file
##### zsh

Put this into your `$HOME/.zshrc` to call `nvm use` automatically whenever you enter a directory that contains an
`.nvmrc` file with a string telling nvm which node to `use`:
Expand Down Expand Up @@ -372,6 +372,23 @@ add-zsh-hook chpwd load-nvmrc
load-nvmrc
```

##### bash

Put this into `$HOME/.bashrc` (or `$HOME/.bash_profile`, or whatever you use) to override the `cd` command to mimic the above zsh-hook:

```bash
# place this after nvm initialization!
load-nvmrc() {
# same definition as zsh-hook
}
load-nvmrc

cd() {
builtin cd "$1"
load-nvmrc
}
```

## License

nvm is released under the MIT license.
Expand Down

0 comments on commit 1e2643a

Please sign in to comment.