Browse Source

Add NVM_COMPLETION option (#63)

NVM_LAZY_LOAD_EXTRA_COMMANDS
Alexandre Faria 5 years ago
committed by GitHub
parent
commit
fdf4d6cc7d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      README.md
  2. 9
      zsh-nvm.plugin.zsh

12
README.md

@ -73,6 +73,18 @@ antigen bundle lukechilds/zsh-nvm
Note: If `nvm` doesn't exist in this directory it'll be automatically installed when you start a session.
### Nvm Completion
`nvm` comes with a default bash_completion profile. If you want to enable it, you can do it by exporting the `NVM_COMPLETION` environment variable and setting it to `true`. It must be set before `zsh-nvm` is loaded.
For example, if you are using antigen, you would put the following in your `.zshrc`:
```bash
# Export nvm completion settings for zsh-nvm plugin
export NVM_COMPLETION=true
antigen bundle lukechilds/zsh-nvm
```
### Lazy Loading
If you find `nvm` adds too much lag to your shell startup you can enable lazy loading by exporting the `NVM_LAZY_LOAD` environment variable and setting it to `true`. It must be set before `zsh-nvm` is loaded.

9
zsh-nvm.plugin.zsh

@ -71,6 +71,12 @@ _zsh_nvm_load() {
}
}
_zsh_nvm_completion() {
# Add provided nvm completion
[[ -r $NVM_DIR/bash_completion ]] && source $NVM_DIR/bash_completion
}
_zsh_nvm_lazy_load() {
# Get all global node module binaries including node
@ -207,6 +213,9 @@ if [[ "$ZSH_NVM_NO_LOAD" != true ]]; then
# Load it
[[ "$NVM_LAZY_LOAD" == true ]] && _zsh_nvm_lazy_load || _zsh_nvm_load
# Enable completion
[[ "$NVM_COMPLETION" == true ]] && _zsh_nvm_completion
# Auto use nvm on chpwd
[[ "$NVM_AUTO_USE" == true ]] && add-zsh-hook chpwd _zsh_nvm_auto_use && _zsh_nvm_auto_use
fi

Loading…
Cancel
Save