mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-10 22:31:51 +00:00
Updated README.md
Added an example for automatically executing nvm use in bash.
This commit is contained in:
parent
a57fe846e8
commit
d815374dbd
24
README.md
24
README.md
@ -21,7 +21,7 @@
|
|||||||
- [.nvmrc](#nvmrc)
|
- [.nvmrc](#nvmrc)
|
||||||
- [Deeper Shell Integration](#deeper-shell-integration)
|
- [Deeper Shell Integration](#deeper-shell-integration)
|
||||||
- [zsh](#zsh)
|
- [zsh](#zsh)
|
||||||
- [Calling `nvm use` automatically in a directory with a `.nvmrc` file](#calling-nvm-use-automatically-in-a-directory-with-a-nvmrc-file)
|
- [bash](#bash)
|
||||||
- [License](#license)
|
- [License](#license)
|
||||||
- [Running tests](#running-tests)
|
- [Running tests](#running-tests)
|
||||||
- [Bash completion](#bash-completion)
|
- [Bash completion](#bash-completion)
|
||||||
@ -101,7 +101,7 @@ If you're running a system without prepackaged binary available, which means you
|
|||||||
- [bass](https://github.com/edc/bass) allows you to use utilities written for Bash in fish shell
|
- [bass](https://github.com/edc/bass) allows you to use utilities written for Bash in fish shell
|
||||||
- [fast-nvm-fish](https://github.com/brigand/fast-nvm-fish) only works with version numbers (not aliases) but doesn't significantly slow your shell startup
|
- [fast-nvm-fish](https://github.com/brigand/fast-nvm-fish) only works with version numbers (not aliases) but doesn't significantly slow your shell startup
|
||||||
- [plugin-nvm](https://github.com/derekstavis/plugin-nvm) plugin for [Oh My Fish](https://github.com/oh-my-fish/oh-my-fish), which makes nvm and its completions available in fish shell
|
- [plugin-nvm](https://github.com/derekstavis/plugin-nvm) plugin for [Oh My Fish](https://github.com/oh-my-fish/oh-my-fish), which makes nvm and its completions available in fish shell
|
||||||
- [fnm](https://github.com/fisherman/fnm) - [fisherman](https://github.com/fisherman/fisherman)-based version manager for fish
|
- [fnm](https://github.com/fisherman/fnm) - [fisherman](https://github.com/fisherman/fisherman)-based version manager for fish
|
||||||
|
|
||||||
**Note:** We still have some problems with FreeBSD, because there is no official pre-built binary for FreeBSD, and building from source may need [patches](https://www.freshports.org/www/node/files/patch-deps_v8_src_base_platform_platform-posix.cc); see the issue ticket:
|
**Note:** We still have some problems with FreeBSD, because there is no official pre-built binary for FreeBSD, and building from source may need [patches](https://www.freshports.org/www/node/files/patch-deps_v8_src_base_platform_platform-posix.cc); see the issue ticket:
|
||||||
- [[#900] [Bug] nodejs on FreeBSD may need to be patched ](https://github.com/creationix/nvm/issues/900)
|
- [[#900] [Bug] nodejs on FreeBSD may need to be patched ](https://github.com/creationix/nvm/issues/900)
|
||||||
@ -351,8 +351,6 @@ If you prefer a lighter-weight solution, the recipes below have been contributed
|
|||||||
|
|
||||||
#### zsh
|
#### zsh
|
||||||
|
|
||||||
##### Calling `nvm use` automatically in a directory with a `.nvmrc` file
|
|
||||||
|
|
||||||
Put this into your `$HOME/.zshrc` to call `nvm use` automatically whenever you enter a directory that contains an
|
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`:
|
`.nvmrc` file with a string telling nvm which node to `use`:
|
||||||
|
|
||||||
@ -380,6 +378,24 @@ add-zsh-hook chpwd load-nvmrc
|
|||||||
load-nvmrc
|
load-nvmrc
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### bash
|
||||||
|
|
||||||
|
Put this into your `$HOME/.bashrc` to call `nvm use` automatically whenever you enter a directory that contains an
|
||||||
|
`.nvmrc` file with a string telling nvm which node to use:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# place this after nvm initialization!
|
||||||
|
cd() {
|
||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
builtin cd
|
||||||
|
else
|
||||||
|
builtin cd $1
|
||||||
|
fi
|
||||||
|
[ -f ".nvmrc" ] && [ -s ".nvmrc" ] && nvm use
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
nvm is released under the MIT license.
|
nvm is released under the MIT license.
|
||||||
|
Loading…
Reference in New Issue
Block a user