Skip to content

Instantly share code, notes, and snippets.

@orzFly
Last active August 29, 2015 14:21
Show Gist options
  • Save orzFly/dd4e7675f69df45c7e23 to your computer and use it in GitHub Desktop.
Save orzFly/dd4e7675f69df45c7e23 to your computer and use it in GitHub Desktop.

Revisions

  1. orzFly renamed this gist May 15, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions nb.zsh → nb.plugin.zsh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    #!/usr/bin/env zsh

    nb() {
    local npmbin="`npm bin`"
    if [ ! -d "$npmbin" ]; then
    @@ -10,8 +12,6 @@ nb() {
    }

    _nb() {
    local curcontext="$curcontext" state line _gems _opts ret=1

    _arguments -C \
    '1: :->cmds' \
    '*:: :->args' && ret=0
  2. orzFly created this gist May 15, 2015.
    36 changes: 36 additions & 0 deletions nb.zsh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    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() {
    local curcontext="$curcontext" state line _gems _opts ret=1

    _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