Skip to content

Instantly share code, notes, and snippets.

@airtonix
Last active March 10, 2023 18:25
Show Gist options
  • Save airtonix/9925531 to your computer and use it in GitHub Desktop.
Save airtonix/9925531 to your computer and use it in GitHub Desktop.
dynamic npm .bin.
# Copy this into your `~/.profile`.
# This setup an incredibly ugly hack that recompiles your `PATH`
# everytime the prompt is printed.
# I need this to inject the nearest `node_modules/.bin` into my
# path to make it easy to use the binarys there.
# Your normal PATH exports here
export PATH=$HOME/bin:$PATH
ORIGINAL_PATH=$PATH
function build_path {
export PATH=$(npm bin):$ORIGINAL_PATH
}
#this line causes the PATH to be regenerated each time a new
# prompt is printed to the screen
PROMPT_COMMAND=build_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment