Created
April 2, 2019 22:20
-
-
Save unique1984/442751f301edd616bc8edd3e848637b0 to your computer and use it in GitHub Desktop.
UFW bash_completion from git@github.com:deleurme/ufw-completion.git
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # vim: ft=sh | |
| # | |
| # ____ | |
| # __ __/ __/ __ | |
| # / / / / /_| | /| / / | |
| # / /_/ / __/| |/ |/ / | |
| # \__,_/_/ |__/|__/ | |
| # | |
| # | |
| _ufw() { | |
| local cur prev opts base | |
| _get_comp_words_by_ref -n : cur | |
| COMPREPLY=() | |
| cur="${COMP_WORDS[COMP_CWORD]}" | |
| prev="${COMP_WORDS[COMP_CWORD-1]}" | |
| last="${COMP_WORDS[COMP_CWORD-2]}" | |
| commands="--dry-run enable disable default logging allow deny reject limit delete insert route route route reload reset status status status show version app" | |
| help_lookup="" | |
| # enable enables the firewall | |
| # disable disables the firewall | |
| # default ARG set default policy | |
| # logging LEVEL set logging to LEVEL | |
| # allow ARGS add allow rule | |
| # deny ARGS add deny rule | |
| # reject ARGS add reject rule | |
| # limit ARGS add limit rule | |
| # delete RULE|NUM delete RULE | |
| # insert NUM RULE insert RULE at NUM | |
| # route RULE add route RULE | |
| # route delete RULE|NUM delete route RULE | |
| # route insert NUM RULE insert route RULE at NUM | |
| # reload reload firewall | |
| # reset reset firewall | |
| # status show firewall status | |
| # status numbered show firewall status as numbered list of RULES | |
| # status verbose show verbose firewall status | |
| # show ARG show firewall report | |
| # version display version information | |
| # Application profile commands: | |
| # app list list application profiles | |
| # app info PROFILE show information on PROFILE | |
| # app update PROFILE update PROFILE | |
| # app default ARG set default application policy | |
| case "${prev}" in | |
| help ) | |
| args=$(for word in $help_lookup;do echo "$word";done) | |
| COMPREPLY=( $(compgen -W "${args}" -- "${cur}") ) | |
| return 0 | |
| ;; | |
| status) | |
| COMPREPLY=( $(compgen -W "numbered verbose" -- "${cur}") ) | |
| return 0 | |
| ;; | |
| logging) | |
| COMPREPLY=( $(compgen -W "off on low medium high full" -- "${cur}") ) | |
| return 0 | |
| ;; | |
| show ) | |
| COMPREPLY=( $(compgen -W "raw builtins before-rules user-rules after-rules logging-rules listening added" -- "${cur}") ) | |
| return 0 | |
| ;; | |
| default) | |
| COMPREPLY=( $(compgen -W "allow deny reject" -- "${cur}") ) | |
| return 0 | |
| ;; | |
| allow) | |
| COMPREPLY=( $(compgen -W "to from" -- "${cur}") ) | |
| return 0 | |
| ;; | |
| route) | |
| COMPREPLY=( $(compgen -W "delete insert" -- "${cur}") ) | |
| return 0 | |
| ;; | |
| info|update) | |
| args=$(ufw app list|awk '{if(NR>1) {print }}') | |
| COMPREPLY=( $(compgen -W "${args}" -- "${cur}") ) | |
| return 0 | |
| ;; | |
| app) | |
| COMPREPLY=( $(compgen -W "list info update default" -- "${cur}") ) | |
| return 0 | |
| ;; | |
| esac | |
| COMPREPLY=($(compgen -W "${commands}" -- "${cur}")) | |
| __ltrim_colon_completions "$cur" | |
| return 0 | |
| } | |
| complete -F _ufw ufw |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment