mirror of
https://github.com/lukechilds/zsh-nvm.git
synced 2025-01-30 09:47:14 +08:00
Add NVM_COMPLETION option (#63)
This commit is contained in:
parent
9f7e144397
commit
fdf4d6cc7d
12
README.md
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.
|
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
|
### 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.
|
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.
|
||||||
|
@ -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() {
|
_zsh_nvm_lazy_load() {
|
||||||
|
|
||||||
# Get all global node module binaries including node
|
# Get all global node module binaries including node
|
||||||
@ -207,6 +213,9 @@ if [[ "$ZSH_NVM_NO_LOAD" != true ]]; then
|
|||||||
# Load it
|
# Load it
|
||||||
[[ "$NVM_LAZY_LOAD" == true ]] && _zsh_nvm_lazy_load || _zsh_nvm_load
|
[[ "$NVM_LAZY_LOAD" == true ]] && _zsh_nvm_lazy_load || _zsh_nvm_load
|
||||||
|
|
||||||
|
# Enable completion
|
||||||
|
[[ "$NVM_COMPLETION" == true ]] && _zsh_nvm_completion
|
||||||
|
|
||||||
# Auto use nvm on chpwd
|
# Auto use nvm on chpwd
|
||||||
[[ "$NVM_AUTO_USE" == true ]] && add-zsh-hook chpwd _zsh_nvm_auto_use && _zsh_nvm_auto_use
|
[[ "$NVM_AUTO_USE" == true ]] && add-zsh-hook chpwd _zsh_nvm_auto_use && _zsh_nvm_auto_use
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user