.bash_completion.d/scoop
changeset 1000 e3e1539cafa9
child 1008 86630b8cd151
equal deleted inserted replaced
999:fb93b077af25 1000:e3e1539cafa9
       
     1 # -*- mode: sh; sh-shell-file: bash -*-
       
     2 
       
     3 
       
     4 _scoop() {
       
     5   local tasks='alias      (Manage scoop aliases)
       
     6 bucket     (Manage Scoop buckets)
       
     7 cache      (Show or clear the download cache)
       
     8 cat        (Show content of specified manifest)
       
     9 checkup    (Check for potential problems)
       
    10 cleanup    (Cleanup apps by removing old versions)
       
    11 config     (Get or set configuration values)
       
    12 create     (Create a custom app manifest)
       
    13 depends    (List dependencies for an app)
       
    14 download   (Download apps in the cache folder and verify hashes)
       
    15 export     (Exports (an importable) list of installed apps)
       
    16 help       (Show help for a command)
       
    17 hold       (Hold an app to disable updates)
       
    18 home       (Opens the app homepage)
       
    19 info       (Display information about an app)
       
    20 install    (Install apps)
       
    21 list       (List installed apps)
       
    22 prefix     (Returns the path to the specified app)
       
    23 reset      (Reset an app to resolve conflicts)
       
    24 search     (Search available apps)
       
    25 shim       (Manipulate Scoop shims)
       
    26 status     (Show status and check for new app versions)
       
    27 unhold     (Unhold an app to enable updates)
       
    28 uninstall  (Uninstall an app)
       
    29 update     (Update apps, or Scoop itself)
       
    30 virustotal (Look for apps hash on virustotal.com)
       
    31 which      (Locate a shim/executable)'
       
    32   local cur prev
       
    33   cur=${COMP_WORDS[COMP_CWORD]}
       
    34   [[ $COMP_CWORD -gt 1 ]] && prev=${COMP_WORDS[COMP_CWORD-1]}
       
    35 
       
    36   if [[ $COMP_CWORD = 1 ]]; then
       
    37     local OIFS="$IFS"
       
    38     local IFS=$'\n'
       
    39     COMPREPLY=( $(compgen -W '$tasks' -- "$cur") )
       
    40     if [[ ${#COMPREPLY[@]} -le 1 ]]; then
       
    41       COMPREPLY=( ${COMPREPLY[0]%% *} )
       
    42     fi
       
    43     IFS=$OIFS
       
    44     return
       
    45   fi
       
    46 
       
    47   local cmd="${COMP_WORDS[1]}"
       
    48   case "$cmd" in
       
    49     cat|depends|download|export|hold|home|info|install|prefix|reset|status|unhold|uninstall|update|virustotal)
       
    50       local dir=`command -v scoop`
       
    51       dir=${dir%/shims/*}/buckets
       
    52       [[ -d "$dir" ]] || return
       
    53       local olddir="$PWD"
       
    54       cd $dir
       
    55       local -a jsons=( */bucket/"$cur"*.json )
       
    56       local -a pkgs=( "${jsons[@]##*/}" )
       
    57       COMPREPLY=( "${pkgs[@]%.json}" )
       
    58       cd "$olddir"
       
    59       return
       
    60     ;;
       
    61   esac
       
    62 }
       
    63 
       
    64 complete -F _scoop scoop