Autoload nvm on specific machines
I don't use nvm version often outside of my work machine, so I like to keep my prompt speedy by lazy loading it. With that, on my work machine, I often forget to manually run nvm and that causes me more grief when I'm trying to run something that had it's dependencies installed by the older version. Sadly, with installing an older version of Node.js on Arch, you don't get the paired version of npm which caused it's own set of additional problems for me. Ideally, once our local dev stack is fully dockerized, I can go back to lazy loading nvm or just dropping it entirely since it won't be necessary at all.
This commit is contained in:
parent
e42350e849
commit
a23d449f6c
2 changed files with 22 additions and 15 deletions
15
aliases
15
aliases
|
@ -78,21 +78,6 @@ function cd {
|
|||
builtin cd "$@" && ls
|
||||
}
|
||||
|
||||
# Run `nvm` init script on demand to avoid constant slow downs
|
||||
function nvm {
|
||||
if [ -z ${NVM_DIR+x} ]; then
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
|
||||
if [ -s "$NVM_DIR/nvm.sh" ]; then
|
||||
source "$NVM_DIR/nvm.sh"
|
||||
elif [ -s "/usr/share/nvm/init-nvm.sh" ]; then
|
||||
source /usr/share/nvm/init-nvm.sh
|
||||
fi
|
||||
|
||||
nvm "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# PID Port
|
||||
function pp {
|
||||
ss -lptn sport = :$1 | grep -Eo 'pid=[0-9]+' | cut -c5-
|
||||
|
|
22
zshrc
22
zshrc
|
@ -65,3 +65,25 @@ PS1='
|
|||
%F{244}%# %F{reset}'
|
||||
|
||||
source $HOME/.fzf.zsh
|
||||
|
||||
# Only autoload nvm on a specific machine, default to lazy loading
|
||||
if [[ $(hostname) == "x1carbon.josh" ]]; then
|
||||
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] \
|
||||
&& printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
else
|
||||
# Run `nvm` init script on demand to avoid constant slow downs
|
||||
function nvm {
|
||||
if [ -z ${NVM_DIR+x} ]; then
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
|
||||
if [ -s "$NVM_DIR/nvm.sh" ]; then
|
||||
source "$NVM_DIR/nvm.sh"
|
||||
elif [ -s "/usr/share/nvm/init-nvm.sh" ]; then
|
||||
source /usr/share/nvm/init-nvm.sh
|
||||
fi
|
||||
|
||||
nvm "$@"
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue