From dfe705f9870c7e2b85684eb466398ea2ef8ddbe2 Mon Sep 17 00:00:00 2001 From: Farid NL <34426099+Farid-NL@users.noreply.github.com> Date: Fri, 22 Mar 2024 13:19:38 -0600 Subject: [PATCH] Add support for xdg base directory --- zsh-nvm.plugin.zsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zsh-nvm.plugin.zsh b/zsh-nvm.plugin.zsh index f4f56f3..e09489e 100644 --- a/zsh-nvm.plugin.zsh +++ b/zsh-nvm.plugin.zsh @@ -1,6 +1,10 @@ ZSH_NVM_DIR=${0:a:h} -[[ -z "$NVM_DIR" ]] && export NVM_DIR="$HOME/.nvm" +_zsh_nvm_default_install_dir() { + [[ -z "${XDG_CONFIG_HOME-}" ]] && echo "$HOME/.nvm" || echo "$XDG_CONFIG_HOME/nvm" +} + +[[ -z "$NVM_DIR" ]] && export NVM_DIR="$(_zsh_nvm_default_install_dir)" _zsh_nvm_rename_function() { test -n "$(declare -f $1)" || return