# HG changeset patch # User Oleksandr Gavenko # Date 1654779669 -10800 # Node ID e3e1539cafa9d0616e00816aacf6a18f2e2dfde0 # Parent fb93b077af25a0acc2a9caaa0f8d181da661ebc3 Added bash autocompletion for Scoop. diff -r fb93b077af25 -r e3e1539cafa9 .bash_completion.d/scoop --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.bash_completion.d/scoop Thu Jun 09 16:01:09 2022 +0300 @@ -0,0 +1,64 @@ +# -*- mode: sh; sh-shell-file: bash -*- + + +_scoop() { + local tasks='alias (Manage scoop aliases) +bucket (Manage Scoop buckets) +cache (Show or clear the download cache) +cat (Show content of specified manifest) +checkup (Check for potential problems) +cleanup (Cleanup apps by removing old versions) +config (Get or set configuration values) +create (Create a custom app manifest) +depends (List dependencies for an app) +download (Download apps in the cache folder and verify hashes) +export (Exports (an importable) list of installed apps) +help (Show help for a command) +hold (Hold an app to disable updates) +home (Opens the app homepage) +info (Display information about an app) +install (Install apps) +list (List installed apps) +prefix (Returns the path to the specified app) +reset (Reset an app to resolve conflicts) +search (Search available apps) +shim (Manipulate Scoop shims) +status (Show status and check for new app versions) +unhold (Unhold an app to enable updates) +uninstall (Uninstall an app) +update (Update apps, or Scoop itself) +virustotal (Look for apps hash on virustotal.com) +which (Locate a shim/executable)' + local cur prev + cur=${COMP_WORDS[COMP_CWORD]} + [[ $COMP_CWORD -gt 1 ]] && prev=${COMP_WORDS[COMP_CWORD-1]} + + if [[ $COMP_CWORD = 1 ]]; then + local OIFS="$IFS" + local IFS=$'\n' + COMPREPLY=( $(compgen -W '$tasks' -- "$cur") ) + if [[ ${#COMPREPLY[@]} -le 1 ]]; then + COMPREPLY=( ${COMPREPLY[0]%% *} ) + fi + IFS=$OIFS + return + fi + + local cmd="${COMP_WORDS[1]}" + case "$cmd" in + cat|depends|download|export|hold|home|info|install|prefix|reset|status|unhold|uninstall|update|virustotal) + local dir=`command -v scoop` + dir=${dir%/shims/*}/buckets + [[ -d "$dir" ]] || return + local olddir="$PWD" + cd $dir + local -a jsons=( */bucket/"$cur"*.json ) + local -a pkgs=( "${jsons[@]##*/}" ) + COMPREPLY=( "${pkgs[@]%.json}" ) + cd "$olddir" + return + ;; + esac +} + +complete -F _scoop scoop