From eb2f40a95d463a5d305974777422e05f4c31f74e Mon Sep 17 00:00:00 2001 From: Augusto Gunsch Date: Sun, 26 Jun 2022 15:41:10 +0200 Subject: [PATCH] Improve nvm usage --- home/aliases | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/home/aliases b/home/aliases index 2f403af..dd4659c 100644 --- a/home/aliases +++ b/home/aliases @@ -53,5 +53,22 @@ goto() { } # NVM - Dynamic loading trick -alias nvm="unalias nvm && [ -z $NVM_LOADED ] && export NVM_LOADED=1 && source /usr/share/nvm/init-nvm.sh ; nvm" -alias node="unalias node && [ -z $NVM_LOADED ] && export NVM_LOADED=1 && source /usr/share/nvm/init-nvm.sh ; node" +alias nvm="load_nvm; nvm" +alias node="load_nvm; node" +alias npm="load_nvm; npm" +alias npx="load_nvm; npx" +alias create-react-app="load_nvm; create-react-app" + +export NVM_DIR="$HOME/.nvm" +load_nvm() { + if [ -z $NVM_LOADED ]; then + export NVM_LOADED=1 + unalias nvm + unalias node + unalias npm + unalias npx + unalias create-react-app + . "$NVM_DIR/nvm.sh" + . "$NVM_DIR/bash_completion" + fi +}