]> arthur.barton.de Git - ax-zsh.git/commitdiff
Add new "nodejs" plugin
authorAlexander Barton <alex@barton.de>
Thu, 25 Apr 2019 13:31:59 +0000 (15:31 +0200)
committerAlexander Barton <alex@barton.de>
Thu, 25 Apr 2019 13:32:24 +0000 (15:32 +0200)
1. Create user-local NPM package directory ~/.npm-packages
2. Setup PATH and MANPATH to include NodeJS search paths

plugins/nodejs/README.md [new file with mode: 0644]
plugins/nodejs/nodejs.zprofile [new file with mode: 0644]

diff --git a/plugins/nodejs/README.md b/plugins/nodejs/README.md
new file mode 100644 (file)
index 0000000..a1a6824
--- /dev/null
@@ -0,0 +1,6 @@
+## nodejs
+
+Enable ZSH *NodeJS* integration:
+
+1. Create user-local NPM package directory ~/.npm-packages
+2. Setup PATH and MANPATH to include NodeJS search paths
diff --git a/plugins/nodejs/nodejs.zprofile b/plugins/nodejs/nodejs.zprofile
new file mode 100644 (file)
index 0000000..807ba23
--- /dev/null
@@ -0,0 +1,19 @@
+# AX-ZSH: Alex' Modular ZSH Configuration
+# nodejs.zprofile: Setup Nodejs (and NPM) environment.
+
+# Make sure that NodeJS is installed
+(( $+commands[node] )) || return
+
+npm_packages="${HOME}/.npm-packages"
+
+if [[ -z "$AXZSH_PLUGIN_CHECK" && ! -d "$npm_packages" ]]; then
+       # Create the user-local NPM package directory (when not running then
+       # "plugin check" right now) and the directory doesn't exist yet:
+       mkdir -p "$npm_packages"
+fi
+
+# Append nodejs paths to binary and manual search paths.
+export PATH="$PATH:$npm_packages/bin"
+export MANPATH="$MANPATH:$npm_packages/share/man"
+
+unset npm_packages