"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/utils/completion.sh" (11 Apr 2017, 1663 Bytes) of package /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/bash
    2 ###-begin-npm-completion-###
    3 #
    4 # npm command completion script
    5 #
    6 # Installation: npm completion >> ~/.bashrc  (or ~/.zshrc)
    7 # Or, maybe: npm completion > /usr/local/etc/bash_completion.d/npm
    8 #
    9 
   10 if type complete &>/dev/null; then
   11   _npm_completion () {
   12     local words cword
   13     if type _get_comp_words_by_ref &>/dev/null; then
   14       _get_comp_words_by_ref -n = -n @ -w words -i cword
   15     else
   16       cword="$COMP_CWORD"
   17       words=("${COMP_WORDS[@]}")
   18     fi
   19 
   20     local si="$IFS"
   21     IFS=$'\n' COMPREPLY=($(COMP_CWORD="$cword" \
   22                            COMP_LINE="$COMP_LINE" \
   23                            COMP_POINT="$COMP_POINT" \
   24                            npm completion -- "${words[@]}" \
   25                            2>/dev/null)) || return $?
   26     IFS="$si"
   27   }
   28   complete -o default -F _npm_completion npm
   29 elif type compdef &>/dev/null; then
   30   _npm_completion() {
   31     local si=$IFS
   32     compadd -- $(COMP_CWORD=$((CURRENT-1)) \
   33                  COMP_LINE=$BUFFER \
   34                  COMP_POINT=0 \
   35                  npm completion -- "${words[@]}" \
   36                  2>/dev/null)
   37     IFS=$si
   38   }
   39   compdef _npm_completion npm
   40 elif type compctl &>/dev/null; then
   41   _npm_completion () {
   42     local cword line point words si
   43     read -Ac words
   44     read -cn cword
   45     let cword-=1
   46     read -l line
   47     read -ln point
   48     si="$IFS"
   49     IFS=$'\n' reply=($(COMP_CWORD="$cword" \
   50                        COMP_LINE="$line" \
   51                        COMP_POINT="$point" \
   52                        npm completion -- "${words[@]}" \
   53                        2>/dev/null)) || return $?
   54     IFS="$si"
   55   }
   56   compctl -K _npm_completion npm
   57 fi
   58 ###-end-npm-completion-###