mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-12 01:52:31 +01:00
feat(fnm): add autostart option to setup fnm env
Add new setting `ZSH_FNM_AUTOSTART` to be able to automatic setup the `fnm env`. Default set to `false` to avoid breaking existing setup.
This commit is contained in:
parent
0e99f402cd
commit
8924759b12
2 changed files with 34 additions and 1 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue