diff options
author | Tobias Brunner <tobias@strongswan.org> | 2011-08-04 17:48:36 +0200 |
---|---|---|
committer | Ville Skyttä <ville.skytta@iki.fi> | 2011-08-20 09:48:16 +0300 |
commit | e4f77de0b797462849c5c6c8639c6071aeceb385 (patch) | |
tree | e250757b015205e44683f91d9c44dc66f47213e2 | |
parent | d271b50f22499b02491c9bcedd15bfc040caab63 (diff) | |
download | bash-completion-e4f77de0b797462849c5c6c8639c6071aeceb385.tar.gz |
ipsec: Complete connection names for 'up', 'down' and other commands.
-rw-r--r-- | completions/ipsec | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/completions/ipsec b/completions/ipsec index 2f66da76..dd757963 100644 --- a/completions/ipsec +++ b/completions/ipsec @@ -2,6 +2,20 @@ # have ipsec || return +# Complete ipsec.conf conn entries. +# +# Reads a file from stdin in the ipsec.conf(5) format. +_ipsec_connections() +{ + COMPREPLY=() + local keyword name + while read -r keyword name; do + if [[ $keyword = [#]* ]]; then continue; fi + [[ $keyword = 'conn' && $name != '%default' ]] && COMPREPLY+=("$name") + done + COMPREPLY=( $( compgen -W '${COMPREPLY[@]}' -- "$cur" ) ) +} + _ipsec_freeswan() { local cur prev words cword @@ -58,6 +72,10 @@ _ipsec_strongswan() fi case ${words[1]} in + down|route|status|statusall|unroute|up) + local confdir=$( ipsec --confdir ) + _ipsec_connections < "$confdir/ipsec.conf" + ;; list*) COMPREPLY=( $( compgen -W '--utc' -- "$cur" ) ) ;; |