This repository has been archived on 2024-01-23. You can view files and clone it, but cannot push or open issues or pull requests.
2017-01-02 05:33:43 +01:00
|
|
|
# Copyright (C) 2017 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
|
|
|
|
|
|
|
_wg_quick_completion() {
|
2017-02-23 04:39:06 +01:00
|
|
|
local i a
|
2017-01-02 05:33:43 +01:00
|
|
|
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}"
|
2017-02-23 04:39:06 +01:00
|
|
|
mapfile -t a < <(compgen -W "$i" -- "${COMP_WORDS[2]}")
|
|
|
|
COMPREPLY+=( "${a[@]}" )
|
2017-01-02 05:33:43 +01:00
|
|
|
done
|
|
|
|
eval "$old_glob"
|
2017-02-23 04:39:06 +01:00
|
|
|
mapfile -t a < <(compgen -f -X '!*.conf' -- "${COMP_WORDS[2]}")
|
|
|
|
COMPREPLY+=( "${a[@]}" )
|
|
|
|
mapfile -t a < <(compgen -d -- "${COMP_WORDS[2]}")
|
|
|
|
COMPREPLY+=( "${a[@]}" )
|
2017-01-02 05:33:43 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
complete -o filenames -o nosort -F _wg_quick_completion wg-quick
|