completions/iptables | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/completions/iptables b/completions/iptables index ffb905b8..ad62737c 100644 --- a/completions/iptables +++ b/completions/iptables @@ -10,8 +10,12 @@ _iptables() [[ ${words[*]} =~ [[:space:]]-(t|-table=?)[[:space:]]*([^[:space:]]+) ]] && table="-t ${BASH_REMATCH[2]}" + if [[ $COMP_LINE == *-E* ]]; then + rename=yes + fi + case $prev in - -*[AIDRPFXLZ]) + -*[AIDRPFXLZEN]) COMPREPLY=($(compgen -W '`"$1" $table -nL 2>/dev/null | \ command sed -ne "s/^Chain \([^ ]\{1,\}\).*$/\1/p"`' -- "$cur")) ;; @@ -37,7 +41,10 @@ _iptables() fi ;; *) - if [[ $cur == -* ]]; then + if [[ "$rename" -eq "yes" ]]; then + COMPREPLY=( $( compgen -W '`iptables $table -nL | \ + sed -ne "s/^Chain \([^ ]\+\).*$/\1/p"`' -- $cur ) ) + elif [[ "$cur" == -* ]]; then COMPREPLY=($(compgen -W '$("$1" --help 2>&1 | command sed -e "s/^\[\!\]//" | _parse_help -)' -- "$cur")) [[ ${COMPREPLY-} == *= ]] && compopt -o nospace