From 880860d4c16d7188832dd40aa7a38032ca18a784 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Mon, 15 Aug 2022 14:46:13 -0500 Subject: [PATCH] Commit to nvm and tweak for Debian --- zsh/.zshrc | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/zsh/.zshrc b/zsh/.zshrc index a882dd4..89d39b7 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -91,31 +91,18 @@ PS1=' %F{blue}%~$(git_prompt) %F{244}%# %F{reset}' -# No lazy loading on macOS if [[ `uname` == Darwin ]]; then + # macOS export NVM_DIR="$HOME/.nvm" [ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" -else - # Only autoload nvm on a specific machine, default to lazy loading - # TODO: Maybe drop the lazy loading entirely as I never use nvm outside of work? - 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 +elif command -v apt &> /dev/null; then + # Debian + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" +elif command -v pacman &> /dev/null; then + # Arch + 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" fi