diff options
author | 2017-09-06 20:51:41 +0200 | |
---|---|---|
committer | 2017-09-06 20:51:41 +0200 | |
commit | 3968a4a5ded90f42f68190ea33fe8e442e301301 (patch) | |
tree | bb304b73694748ce2ffb94af3c16d00ecb899511 | |
parent | tools: fix removal of psk (diff) | |
download | wireguard-monolithic-historical-3968a4a5ded90f42f68190ea33fe8e442e301301.tar.xz wireguard-monolithic-historical-3968a4a5ded90f42f68190ea33fe8e442e301301.zip |
wg-quick: only bash complete existing interfaces for down
-rw-r--r-- | src/tools/completion/wg-quick.bash-completion | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/tools/completion/wg-quick.bash-completion b/src/tools/completion/wg-quick.bash-completion index e0bdf9f..b931323 100644 --- a/src/tools/completion/wg-quick.bash-completion +++ b/src/tools/completion/wg-quick.bash-completion @@ -4,20 +4,23 @@ _wg_quick_completion() { local i a if [[ $COMP_CWORD -eq 1 ]]; then COMPREPLY+=( $(compgen -W "up down" -- "${COMP_WORDS[1]}") ) - return elif [[ $COMP_CWORD -eq 2 ]]; then - local old_glob="$(shopt -p nullglob)" - shopt -s nullglob - for i in /etc/wireguard/*.conf; do - i="${i##*/}"; i="${i%.conf}" - mapfile -t a < <(compgen -W "$i" -- "${COMP_WORDS[2]}") + if [[ ${COMP_WORDS[1]} == up ]]; then + local old_glob="$(shopt -p nullglob)" + shopt -s nullglob + for i in /etc/wireguard/*.conf; do + i="${i##*/}"; i="${i%.conf}" + mapfile -t a < <(compgen -W "$i" -- "${COMP_WORDS[2]}") + COMPREPLY+=( "${a[@]}" ) + done + eval "$old_glob" + mapfile -t a < <(compgen -f -X '!*.conf' -- "${COMP_WORDS[2]}") COMPREPLY+=( "${a[@]}" ) - done - eval "$old_glob" - mapfile -t a < <(compgen -f -X '!*.conf' -- "${COMP_WORDS[2]}") - COMPREPLY+=( "${a[@]}" ) - mapfile -t a < <(compgen -d -- "${COMP_WORDS[2]}") - COMPREPLY+=( "${a[@]}" ) + mapfile -t a < <(compgen -d -- "${COMP_WORDS[2]}") + COMPREPLY+=( "${a[@]}" ) + elif [[ ${COMP_WORDS[1]} == down ]]; then + COMPREPLY+=( $(compgen -W "$(wg show interfaces)" -- "${COMP_WORDS[2]}") ) + fi fi } |