admin-trinkets/scripts/hopon/010_hopon_completion.bash

23 lines
540 B
Bash
Raw Permalink Normal View History

2024-09-25 15:42:11 +00:00
#/usr/bin/env bash
_hopon_completions () {
# Check to see if a container/VM manager is installed.
local vm_manager=""
if [ -x "$(command -v incus)" ]; then
vm_manager="incus"
elif [ -x "$(command -v lxc)" ]; then
vm_manager="lxc"
else
return
fi
# We only want one copy of the found parameter.
if [ "${#COMP_WORDS[@]}" != "2" ]; then
return
fi
COMPREPLY=($(compgen -W "$($vm_manager list -c n -f csv)" -- "${COMP_WORDS[1]}"))
}
complete -F _hopon_completions hopon