21 lines
645 B
Plaintext
21 lines
645 B
Plaintext
|
# Copyright (C) 2017 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
||
|
|
||
|
_wg_quick_completion() {
|
||
|
local i
|
||
|
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}"
|
||
|
COMPREPLY+=( $(compgen -W "$i" -- "${COMP_WORDS[2]}") )
|
||
|
done
|
||
|
eval "$old_glob"
|
||
|
COMPREPLY+=( $(compgen -f -X '!*.conf' -- "${COMP_WORDS[2]}") $(compgen -d -- "${COMP_WORDS[2]}") )
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
complete -o filenames -o nosort -F _wg_quick_completion wg-quick
|