_sysdig_complete() { local opts=' \ -A \ --print-ascii \ -b \ --print-base64 \ -C \ --file-size \ -cl \ --list-chisels \ -d \ --displayflt \ -D \ --debug \ -e \ --events \ -E \ --exclude-users \ -F \ --fatfile \ -G \ --seconds \ -h \ --help \ -j \ --json \ -k \ --k8s-api \ -L \ --list-events \ -l \ --list \ -lv \ --page-faults \ -P \ --progress \ -q \ --quiet \ -R \ --resolve-ports \ -S \ --summary \ -v \ --verbose \ -x \ --print-hex \ -X \ --print-hex-ascii \ -z \ --compress \ -n \ --numevents \ -p \ --print \ -r \ --read \ -w \ --write \ -W \ --limit \ -s \ --snaplen \ -t \ --timetype \ -c \ --chisel \ -i \ --chisel-info' local cur=${COMP_WORDS[COMP_CWORD]} local prev=${COMP_WORDS[COMP_CWORD-1]} case "$prev" in -c|--chisel|-i|--chisel-info) local chisels="" local detail="Use the -i flag to get detailed information about a specific chisel" while IFS= read -r line do if [[ $line =~ "---" ]]; then # skip lines such as # ----------------- continue; elif [[ -z "$line" ]]; then # empty lines reset the category continue; elif [[ $line =~ "Category" ]]; then # category continue; elif [[ $line =~ $detail ]]; then # detail instructions continue; fi local chisel=${line%% *} if [[ -z "$chisel" ]]; then # empty lines from description continue; fi chisels="$chisels $chisel" done < <(sysdig -cl) COMPREPLY=( $( compgen -W "$chisels" -- $cur ) ) return 0 ;; esac # completing an option if [[ "$cur" == -* ]]; then COMPREPLY=( $( compgen -W "$opts" -- $cur ) ) fi } complete -o default -F _sysdig_complete sysdig # Local Variables: # mode:sh # End: