wg: fix bash completion spaces
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
bda4b8c60b
commit
aefa5e8edc
|
@ -1,7 +1,7 @@
|
||||||
# Copyright (C) 2017 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
# Copyright (C) 2017 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
||||||
|
|
||||||
_wg_quick_completion() {
|
_wg_quick_completion() {
|
||||||
local i
|
local i a
|
||||||
if [[ $COMP_CWORD -eq 1 ]]; then
|
if [[ $COMP_CWORD -eq 1 ]]; then
|
||||||
COMPREPLY+=( $(compgen -W "up down" -- "${COMP_WORDS[1]}") )
|
COMPREPLY+=( $(compgen -W "up down" -- "${COMP_WORDS[1]}") )
|
||||||
return
|
return
|
||||||
|
@ -10,10 +10,14 @@ _wg_quick_completion() {
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
for i in /etc/wireguard/*.conf; do
|
for i in /etc/wireguard/*.conf; do
|
||||||
i="${i##*/}"; i="${i%.conf}"
|
i="${i##*/}"; i="${i%.conf}"
|
||||||
COMPREPLY+=( $(compgen -W "$i" -- "${COMP_WORDS[2]}") )
|
mapfile -t a < <(compgen -W "$i" -- "${COMP_WORDS[2]}")
|
||||||
|
COMPREPLY+=( "${a[@]}" )
|
||||||
done
|
done
|
||||||
eval "$old_glob"
|
eval "$old_glob"
|
||||||
COMPREPLY+=( $(compgen -f -X '!*.conf' -- "${COMP_WORDS[2]}") $(compgen -d -- "${COMP_WORDS[2]}") )
|
mapfile -t a < <(compgen -f -X '!*.conf' -- "${COMP_WORDS[2]}")
|
||||||
|
COMPREPLY+=( "${a[@]}" )
|
||||||
|
mapfile -t a < <(compgen -d -- "${COMP_WORDS[2]}")
|
||||||
|
COMPREPLY+=( "${a[@]}" )
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# Copyright (C) 2017 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
# Copyright (C) 2017 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
||||||
|
|
||||||
_wg_completion() {
|
_wg_completion() {
|
||||||
|
local a
|
||||||
|
|
||||||
if [[ $COMP_CWORD -eq 1 ]]; then
|
if [[ $COMP_CWORD -eq 1 ]]; then
|
||||||
COMPREPLY+=( $(compgen -W "show showconf set setconf addconf genkey genpsk pubkey" -- "${COMP_WORDS[1]}") )
|
COMPREPLY+=( $(compgen -W "show showconf set setconf addconf genkey genpsk pubkey" -- "${COMP_WORDS[1]}") )
|
||||||
return
|
return
|
||||||
|
@ -25,7 +27,8 @@ _wg_completion() {
|
||||||
|
|
||||||
if [[ $COMP_CWORD -eq 3 && ( ${COMP_WORDS[1]} == setconf || ${COMP_WORDS[1]} == addconf ) ]]; then
|
if [[ $COMP_CWORD -eq 3 && ( ${COMP_WORDS[1]} == setconf || ${COMP_WORDS[1]} == addconf ) ]]; then
|
||||||
compopt -o filenames
|
compopt -o filenames
|
||||||
COMPREPLY+=( $(compgen -f -- "${COMP_WORDS[3]}") )
|
mapfile -t a < <(compgen -f -- "${COMP_WORDS[3]}")
|
||||||
|
COMPREPLY+=( "${a[@]}" )
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -49,7 +52,8 @@ _wg_completion() {
|
||||||
COMPREPLY+=( $(compgen -W "${words[*]}" -- "${COMP_WORDS[COMP_CWORD]}") )
|
COMPREPLY+=( $(compgen -W "${words[*]}" -- "${COMP_WORDS[COMP_CWORD]}") )
|
||||||
elif [[ ${COMP_WORDS[COMP_CWORD-1]} == *-key ]]; then
|
elif [[ ${COMP_WORDS[COMP_CWORD-1]} == *-key ]]; then
|
||||||
compopt -o filenames
|
compopt -o filenames
|
||||||
COMPREPLY+=( $(compgen -f -- "${COMP_WORDS[COMP_CWORD]}") )
|
mapfile -t a < <(compgen -f -- "${COMP_WORDS[COMP_CWORD]}")
|
||||||
|
COMPREPLY+=( "${a[@]}" )
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue