home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / bash_completion.d / iptables < prev    next >
Encoding:
Text File  |  2010-11-16  |  2.3 KB  |  71 lines

  1. # bash completion for iptables
  2.  
  3. have iptables &&
  4. _iptables()
  5. {
  6.     local cur prev table chain
  7.  
  8.     COMPREPLY=()
  9.     _get_comp_words_by_ref cur prev
  10.     chain='s/^Chain \([^ ]\{1,\}\).*$/\1/p'
  11.  
  12.     if [[ $COMP_LINE == *-t\ *filter* ]]; then
  13.         table="-t filter"
  14.     elif [[ $COMP_LINE == *-t\ *nat* ]]; then
  15.         table="-t nat"
  16.     elif [[ $COMP_LINE == *-t\ *mangle* ]]; then
  17.         table="-t mangle"
  18.     fi
  19.  
  20.     _split_longopt
  21.  
  22.     case $prev in
  23.     -*[AIDRPFXLZ])
  24.         COMPREPLY=( $( compgen -W '`iptables $table -nL | \
  25.                 sed -ne "s/^Chain \([^ ]\{1,\}\).*$/\1/p"`' -- "$cur" ) )
  26.         ;;
  27.     -*t)
  28.         COMPREPLY=( $( compgen -W 'nat filter mangle' -- "$cur" ) )
  29.         ;;
  30.     -j)
  31.         if [[ "$table" == "-t filter" || -z "$table" ]]; then
  32.             COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
  33.                 `iptables $table -nL | sed -ne "$chain" \
  34.                 -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
  35.                 "$cur" ) )
  36.         elif [ "$table" = "-t nat" ]; then
  37.             COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
  38.                 MIRROR SNAT DNAT MASQUERADE `iptables $table -nL | \
  39.                 sed -ne "$chain" -e "s/OUTPUT|PREROUTING|POSTROUTING//"`' \
  40.                 -- "$cur" ) )
  41.         elif [ "$table" = "-t mangle" ]; then
  42.             COMPREPLY=( $( compgen -W 'ACCEPT DROP LOG ULOG REJECT \
  43.                 MARK TOS `iptables $table -nL | sed -ne "$chain" \
  44.                 -e "s/INPUT|OUTPUT|FORWARD|PREROUTING|POSTROUTING//"`' -- \
  45.                 "$cur" ) )
  46.         fi
  47.         ;;
  48.     *)
  49.         if [[ "$cur" == -* ]]; then
  50.             COMPREPLY=( $( compgen -W '--in-interface --out-interface --source \
  51.                 --destination --protocol --fragment --match --append \
  52.                 --delete --insert --replace --list --flush --zero --new \
  53.                 --delete-chain --policy --rename-chain --proto --source \
  54.                 --destination --in-interface --jump --match --numeric \
  55.                 --out-interface --table --verbose --line-numbers --exact \
  56.                 --fragment --modprobe --set-counters --version' -- "$cur") )
  57.         fi
  58.         ;;
  59.     esac
  60.  
  61. } &&
  62. complete -F _iptables iptables
  63.  
  64. # Local variables:
  65. # mode: shell-script
  66. # sh-basic-offset: 4
  67. # sh-indent-comment: t
  68. # indent-tabs-mode: nil
  69. # End:
  70. # ex: ts=4 sw=4 et filetype=sh
  71.