Skip to content

Instantly share code, notes, and snippets.

@anatooly
Last active November 20, 2020 11:48
Show Gist options
  • Save anatooly/758fa0c07df9e767cc4f632447e9c1f2 to your computer and use it in GitHub Desktop.
Save anatooly/758fa0c07df9e767cc4f632447e9c1f2 to your computer and use it in GitHub Desktop.
ZSH project node_modules bin file run
# Adds node_modules/.bin to the PATH
# vi -c ":set nobomb" -c ":wq" ~/.zshrc macOs utf-8 char problem
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