Skip to content

Instantly share code, notes, and snippets.

@gturi
Last active July 21, 2023 16:43
Show Gist options
  • Save gturi/bc26e966ed472e70b5f7ee9038db55f8 to your computer and use it in GitHub Desktop.
Save gturi/bc26e966ed472e70b5f7ee9038db55f8 to your computer and use it in GitHub Desktop.

Lazy load bashrc scripts

nvm example

export NVM_DIR="$HOME/.nvm"

function loadNvm() {
  [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
}

# careful: bash completion can't be lazily loaded or otherwise it will not work!
# (maybe there is a trick to do that but it needs further investigations...)
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

loadNvm &
@gturi
Copy link
Author

gturi commented Jul 21, 2023

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