Add NVM_COMPLETION option (#63)

This commit is contained in:
Alexandre Faria 2020-05-01 12:42:28 +02:00 committed by GitHub
parent 9f7e144397
commit fdf4d6cc7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -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.

View File

@ -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