mirror of https://github.com/ohmyzsh/ohmyzsh.git
Compare commits
2 Commits
8c07bf6b97
...
d12d182264
Author | SHA1 | Date |
---|---|---|
|
d12d182264 | |
|
8924759b12 |
|
@ -2,8 +2,30 @@
|
|||
|
||||
This plugin adds autocompletion for [fnm](https://github.com/Schniz/fnm) - a Node.js version manager.
|
||||
|
||||
To use it, add `fnm` to the plugins array in your zshrc file:
|
||||
To use it, add `fnm` to the plugins array in your `.zshrc` file:
|
||||
|
||||
```zsh
|
||||
plugins=(... fnm)
|
||||
```
|
||||
|
||||
## Configuration Variables
|
||||
|
||||
These settings should go in your `.zshrc` file, before Oh My Zsh is sourced.
|
||||
|
||||
For example:
|
||||
|
||||
```sh
|
||||
ZSH_FNM_AUTOSTART=true
|
||||
...
|
||||
plugins=(... fnm)
|
||||
source "$ZSH/oh-my-zsh.sh"
|
||||
```
|
||||
|
||||
The following variables are available to this plugin customization:
|
||||
|
||||
| Variable | Default | Meaning |
|
||||
| :------- | :-----: | ------- |
|
||||
| `ZSH_FNM_AUTOSTART` | `false` | Automatically starts fnm for the session, running the `fnm env` |
|
||||
| `ZSH_FNM_USE_ON_CD` | `true` | Switch the Node.js version based on the requirements of the current directory (recommended) |
|
||||
|
||||
Check out the [official documentation](https://github.com/Schniz/fnm/blob/master/docs/commands.md) for the available fnm variables.
|
||||
|
|
|
@ -2,6 +2,11 @@ if (( ! $+commands[fnm] )); then
|
|||
return
|
||||
fi
|
||||
|
||||
# CONFIGURATION VARIABLES
|
||||
# Automatically start the fnm multishell
|
||||
: ${ZSH_FNM_AUTOSTART:=false} # opt-in to avoid duplicated sessions
|
||||
: ${ZSH_FNM_USE_ON_CD:=true} # upstream recommendation
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it to `fnm`. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnm" ]]; then
|
||||
|
@ -11,3 +16,9 @@ if [[ ! -f "$ZSH_CACHE_DIR/completions/_fnm" ]]; then
|
|||
fi
|
||||
|
||||
fnm completions --shell=zsh >| "$ZSH_CACHE_DIR/completions/_fnm" &|
|
||||
|
||||
if [[ "$ZSH_FNM_AUTOSTART" == "true" ]]; then
|
||||
local -a fnm_env_cmd
|
||||
[[ "$ZSH_FNM_USE_ON_CD" == "true" ]] && fnm_env_cmd+=("--use-on-cd")
|
||||
eval "$(fnm env --shell=zsh $fnm_env_cmd)"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue