diff options
Diffstat (limited to 'etc/bash_completion.d/wg-activate')
| -rw-r--r-- | etc/bash_completion.d/wg-activate | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/etc/bash_completion.d/wg-activate b/etc/bash_completion.d/wg-activate new file mode 100644 index 0000000..a0f5486 --- /dev/null +++ b/etc/bash_completion.d/wg-activate @@ -0,0 +1,24 @@ +#/usr/bin/env bash +## SPDX-FileCopyrightText: 2022 M. Shulhan <ms@kilabit.info> +## SPDX-License-Identifier: GPL-3.0-or-later + +_wg-activate_completions() +{ + confs=$(find -L /etc/wireguard -maxdepth 1 -type f -name "*.conf" -print) + + names=() + for f in $confs; do + got=$(basename "${f%.conf}") + names+=("$got") + done + + if [[ -z "${COMP_WORDS[1]}" ]]; then + COMPREPLY=("${names[@]}") + return + fi + + words="${names[@]}" + COMPREPLY=($(compgen -W "$words" -- "${COMP_WORDS[1]}")) +} + +complete -F _wg-activate_completions wg-activate.sh |
