Last active
August 29, 2015 14:23
-
-
Save lalomartins/e04317bd953f954bb0a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
VERSION="$1" | |
shift | |
for bin in "$@"; do | |
binpath=$(realpath -s "${bin}") | |
echo "${binpath} -> ${VERSION}" | |
wrapperpath="${HOME}/.local/bin/$(basename "${bin}")" | |
if [ -e "${wrapperpath}" ]; then | |
echo "${wrapperpath} already exists, leaving alone!" | |
continue | |
fi | |
echo "create ${wrapperpath}" | |
cat > "${wrapperpath}" <<-EOF | |
#!/bin/sh | |
export NVM_DIR="${HOME}/.nvm" | |
. \${NVM_DIR}/nvm.sh | |
nvm use ${VERSION} | |
exec "${binpath}" "\$@" | |
EOF | |
chmod u+x "${wrapperpath}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment