wireguard-tools/src/completion/wg-quick.bash-completion
Greg Kroah-Hartman 01d00bc035 global: add SPDX tags to all files
It's good to have SPDX identifiers in all files as the Linux kernel
developers are working to add these identifiers to all files.

Update all files with the correct SPDX license identifier based on the license
text of the project or based on the license in the file itself.  The SPDX
identifier is a legally binding shorthand, which can be used instead of the
full boiler plate text.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Modified-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2017-12-09 22:29:28 +01:00

29 lines
956 B
Plaintext

# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2015-2017 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
_wg_quick_completion() {
local i a
if [[ $COMP_CWORD -eq 1 ]]; then
COMPREPLY+=( $(compgen -W "up down" -- "${COMP_WORDS[1]}") )
elif [[ $COMP_CWORD -eq 2 ]]; then
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[@]}" )
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
}
complete -o filenames -o nosort -F _wg_quick_completion wg-quick