23 lines
540 B
Bash
23 lines
540 B
Bash
|
#/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
|