diff options
Diffstat (limited to 'completions/nmap')
-rw-r--r-- | completions/nmap | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/completions/nmap b/completions/nmap index b4e76baf..482148e3 100644 --- a/completions/nmap +++ b/completions/nmap @@ -2,15 +2,15 @@ _nmap() { - local cur prev words cword - _init_completion || return + local cur prev words cword split + _init_completion -s || return case $prev in - -iL|-oN|-oX|-oS|-oG|---excludefile|--resume|--stylesheet) + -iL | -oN | -oX | -oS | -oG | ---excludefile | --resume | --stylesheet) _filedir return ;; - -oA|--datadir) + -oA | --datadir) _filedir -d return ;; @@ -18,33 +18,39 @@ _nmap() _available_interfaces -a return ;; - -b|--dns-servers) + -b | --dns-servers) _known_hosts_real -- "$cur" return ;; esac - if [[ "$cur" == -* ]]; then - COMPREPLY=( $(compgen -W '-iL -iR --exclude --excludefile -sL -sP -PN - -PS -PA -PU -PY -PE -PP -PM -PO -n -R --dns-servers --system-dns - --traceroute -sS -sT -sA -sW -sM -sU -sN -sF -sX --scanflags -sI - -sY -sZ -sO -b -p -F -r --top-ports --port-ratio -sV - --version-intensity --version-light --version-all --version-trace - -sC --script= --script-args= --script-trace --script-updatedb -O - --osscan-limit --osscan-guess -T0 -T1 -T2 -T3 -T4 -T5 - --min-hostgroup --max-hostgroup --min-parallelism --max-parallelism - --min-rtt-timeout --max-rtt-timeout --initial-rtt-timeout - --max-retries --host-timeout --scan-delay --max-scan-delay - --min-rate --max-rate -f --mtu -D -S -e --source-port --data-length - --ip-options --ttl --spoof-mac --badsum --adler32 -oN -oX -oS -oG - -oA -v -d --reason --open --packet-trace --iflist --log-errors - --append-output --resume --stylesheet --webxml --no-stylesheet -6 - -A --datadir --send-eth --send-ip --privilege--unprivileged -V - -h' -- "$cur") ) + $split && return + + if [[ $cur == -* ]]; then + # strip everything following a :, inclusive + # strip everything following a =, exclusive + # expand -X; -Y to -X -Y + # expand -X/-Y/-Z to -X -Y -Z + # expand -X/Y/Z to -X -Y -Z + # expand --foo/bar to --foo --bar + # strip everything following a non-option name or = char + # TODO: should expand -T<0-5> to -T0 ... -T5 + COMPREPLY=($(compgen -W "$( + "$1" --help 2>&1 | command sed \ + -e "s/:.*$//" \ + -e "s/=.*$/=/" \ + -e "s/;[[:space:]]*-/ -/g" \ + -e "s/\/-/ -/g" \ + -e "/^[[:space:]]*-[^-]/s/\/\([^-]\)/ -\1/g" \ + -e "/^[[:space:]]*--/s/\/\([^-]\)/ --\1/g" \ + -e "s/[^[:space:]a-zA-Z0-9=-].*$//" + )" \ + -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else _known_hosts_real -- "$cur" fi } && -complete -F _nmap nmap + complete -F _nmap nmap # ex: filetype=sh |