Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1#!/usr/bin/env bash 2# based on https://github.com/urfave/cli/blob/v2.3.0/autocomplete/bash_autocomplete 3 4_cli_bash_autocomplete() { 5 if [[ "${COMP_WORDS[0]}" != "source" ]]; then 6 local cur opts 7 COMPREPLY=() 8 cur="${COMP_WORDS[COMP_CWORD]}" 9 if [[ "$cur" == "-"* ]]; then 10 opts=$("${COMP_WORDS[@]:0:$COMP_CWORD}" "${cur}" --generate-bash-completion) 11 else 12 opts=$("${COMP_WORDS[@]:0:$COMP_CWORD}" --generate-bash-completion) 13 fi 14 IFS=$'\n' read -d '' -ra COMPREPLY < <(compgen -W "${opts}" -- "${cur}") 15 return 0 16 fi 17} 18 19complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete sops