Skip to content

Instantly share code, notes, and snippets.

@nunofgs
Forked from puffnfresh/npm_chpwd_hook.sh
Last active November 9, 2020 02:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nunofgs/bd99074e2620d769be20e123a341bfd8 to your computer and use it in GitHub Desktop.
Save nunofgs/bd99074e2620d769be20e123a341bfd8 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