Skip to content

Instantly share code, notes, and snippets.

@xenophonf
Created October 18, 2024 13:48
Show Gist options
  • Save xenophonf/55ddae19078549eeede183e0d19a798d to your computer and use it in GitHub Desktop.
Save xenophonf/55ddae19078549eeede183e0d19a798d to your computer and use it in GitHub Desktop.
A wrapper for nvm that makes it work in other shells (specifically, csh and tcsh)
#!/usr/bin/env bash
# load nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] || exit 0
\. "$NVM_DIR/nvm.sh"
# configure csh
if [ "$1" = "csh-env" ]; then
# use the 'default' version by default
if [ -z "$2" ]; then
set -- csh-env default
fi
nvm exec --silent "$2" printenv \
| fgrep .nvm \
| sed -e 's/^\(.*\)=\(.*\)/setenv \1 "\2";/'
exit 0
fi
nvm "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment