Skip to content

Instantly share code, notes, and snippets.

@lukeshiru

lukeshiru/nvm-fix.zsh.sh Secret

Last active Apr 23, 2021
Embed
What would you like to do?
if [ -s "$HOME/.nvm/nvm.sh" ] && [ ! "$(type -f __init_nvm)" = function ]; then
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"
declare -a __node_commands=(nvm `find -L $NVM_DIR/versions/*/*/bin -type f -exec basename {} \; | sort -u`)
function __init_nvm() {
for i in "${__node_commands[@]}"; do unalias $i; done
. "$NVM_DIR"/nvm.sh
unset __node_commands
unset -f __init_nvm
}
for i in "${__node_commands[@]}"; do alias $i='__init_nvm && '$i; done
fi
@barnacle-recursion

This comment has been minimized.

Copy link

@barnacle-recursion barnacle-recursion commented Oct 14, 2018

Great snippet!

@jcklpe

This comment has been minimized.

Copy link

@jcklpe jcklpe commented Nov 24, 2018

This didn't fix my nvm slowness per se but it did get it to stop complaining every time I loaded it up that N/A wasn't installed in N/A.

@anishmittal2020

This comment has been minimized.

Copy link

@anishmittal2020 anishmittal2020 commented Jan 26, 2019

@lukeshiru Why did you change -t to -f ? Can't find the options in the man page.

@lukeshiru

This comment has been minimized.

Copy link
Owner Author

@lukeshiru lukeshiru commented Mar 15, 2019

Sorry for the late response @anishmittal2020, I just noticed your comment: -t isn't valid in zsh, so you need to use -f instead. Maybe this link is useful for you: https://serverfault.com/questions/879222/get-on-zsh-the-same-result-you-get-when-executing-type-t-on-bash

@katafractari

This comment has been minimized.

Copy link

@katafractari katafractari commented Nov 19, 2019

This has fixed my nvm slowness!

@lukeshiru

This comment has been minimized.

Copy link
Owner Author

@lukeshiru lukeshiru commented Nov 19, 2019

I'm glad, @katafractari!

@tovbinm

This comment has been minimized.

Copy link

@tovbinm tovbinm commented Apr 10, 2020

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment