#!/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