Skip to content

Instantly share code, notes, and snippets.

@puffnfresh
Created November 27, 2012 01:17
Show Gist options
  • Save puffnfresh/4151775 to your computer and use it in GitHub Desktop.
Save puffnfresh/4151775 to your computer and use it in GitHub Desktop.
Adds node_modules/.bin to the PATH (zsh)
# Adds node_modules/.bin to the PATH
npm_chpwd_hook() {
if [ -n "${PRENPMPATH+x}" ]; then
PATH=$PRENPMPATH
unset PRENPMPATH
fi
if [ -f package.json ]; then
PRENPMPATH=$PATH
PATH=$(npm bin):$PATH
fi
}
add-zsh-hook preexec npm_chpwd_hook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment