Skip to content

Instantly share code, notes, and snippets.

View hypest's full-sized avatar
😎
Working from anywhere

Stefanos Togoulidis hypest

😎
Working from anywhere
View GitHub Profile
@hypest
hypest / .bash_profile
Created February 7, 2021 23:00
Defer nvm init to speed up bash init. Just backin up the solution found in https://www.growingwiththeweb.com/2018/01/slow-nvm-init.html
# Defer initialization of nvm until nvm, node or a node-dependent command is
# run. Ensure this block is only run once if .bashrc gets sourced multiple times
# by checking whether __init_nvm is a function.
if [ -s "$HOME/.nvm/nvm.sh" ] && [ ! "$(type -t __init_nvm)" = function ]; then
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"
declare -a __node_commands=('nvm' 'node' 'npm' 'yarn' 'gulp' 'grunt' 'webpack')
function __init_nvm() {
for i in "${__node_commands[@]}"; do unalias $i; done
. "$NVM_DIR"/nvm.sh