Last active
August 29, 2015 14:21
-
-
Save orzFly/dd4e7675f69df45c7e23 to your computer and use it in GitHub Desktop.
NB: npm bin wrapper for zsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
nb() { | |
local npmbin="`npm bin`" | |
if [ ! -d "$npmbin" ]; then | |
echo "NB is not available at $npmbin" | |
return 1 | |
fi | |
local command="$1" | |
builtin shift 1 | |
"$npmbin/$command" $* | |
} | |
_nb() { | |
_arguments -C \ | |
'1: :->cmds' \ | |
'*:: :->args' && ret=0 | |
case $state in | |
cmds) | |
local npmbin="`npm bin`" | |
if [ ! -d "$npmbin" ]; then | |
return 1 | |
fi | |
_path_files -W "$npmbin" | |
ret=0 | |
;; | |
args) | |
_normal && ret=0 | |
;; | |
esac | |
return ret | |
} | |
compdef _nb nb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment