# SPDX-License-Identifier: GPL-2.0-or-later # Copyright (c) 2026 Steve Grubb _pscap() { local cur prev local opts="-a -p --tree" COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case "$prev" in -p) COMPREPLY=( $(compgen -W "$(ps -eo pid= 2>/dev/null)" \ -- "$cur") ) return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) fi } _netcap() { local cur prev local opts="--advanced --interface --list-interfaces --json --no-color" COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" case "$prev" in --interface) COMPREPLY=( $(compgen -W "$(command ls /sys/class/net \ 2>/dev/null)" -- "$cur") ) return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) fi } _filecap() { local cur prev local opts="-a -d" COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" if [[ "$cur" == -* ]]; then COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) return 0 fi case "$prev" in -a|-d) return 0 ;; esac if [[ "$cur" == /* ]]; then # Keep spaces and glob characters within each filename. -f also # includes directories, so a separate -d pass duplicates them. mapfile -t COMPREPLY < <(compgen -f -- "$cur") fi } _cap_audit() { local cur prev local opts="-h --help -v --verbose -j --json -y --yaml -s --service --" COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" if [[ "$prev" == "--" ]]; then # Executable names may contain whitespace too. mapfile -t COMPREPLY < <(compgen -c -- "$cur") return 0 fi case "$prev" in -s|--service) mapfile -t COMPREPLY < <(compgen -f -- "$cur") return 0 ;; esac if [[ "$cur" == -* ]]; then COMPREPLY=( $(compgen -W "$opts" -- "$cur") ) else mapfile -t COMPREPLY < <(compgen -c -- "$cur") fi } complete -F _pscap pscap complete -F _netcap netcap # Tell Readline to quote filenames on insertion and append directory slashes. complete -o filenames -F _filecap filecap complete -o filenames -F _cap_audit cap-audit