Skip to content

Instantly share code, notes, and snippets.

@mingtsay
Forked from nunofgs/npm_chpwd_hook.sh
Created November 9, 2020 02:09
Show Gist options
  • Save mingtsay/1917241d90a63fa1a29f109faa9e707d to your computer and use it in GitHub Desktop.
Save mingtsay/1917241d90a63fa1a29f109faa9e707d to your computer and use it in GitHub Desktop.
Adds node_modules/.bin to the PATH (zsh)
if ((!$+commands[npm])); then
return 1
fi
# Adds node_modules/.bin to the PATH
npm_bin_hook() {
if [ -n "${OLDPATH+x}" ]; then
PATH=$OLDPATH
unset OLDPATH
fi
if [ -f package.json ]; then
OLDPATH=$PATH
PATH=$PWD/node_modules/.bin:$PATH
fi
}
add-zsh-hook chpwd npm_bin_hook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment