mirror of
https://github.com/gryf/vboxmanage-bash-completion.git
synced 2026-03-25 19:13:31 +01:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dffdf72bb9 |
@@ -6,7 +6,7 @@ script. However, in some point of time I've decided to rewrite it almost from
|
|||||||
scratch.
|
scratch.
|
||||||
|
|
||||||
Current version of script was written and tested against VBoxManage in version
|
Current version of script was written and tested against VBoxManage in version
|
||||||
7.1.8, and should contain all commands and their options.
|
7.2.4, and should contain all commands and their options.
|
||||||
|
|
||||||
Unlike other attempts, I've tried to make the script context aware. See the
|
Unlike other attempts, I've tried to make the script context aware. See the
|
||||||
simple session with the VBoxManage command below, to have an idea how it works:
|
simple session with the VBoxManage command below, to have an idea how it works:
|
||||||
|
|||||||
137
VBoxManage
137
VBoxManage
@@ -3,7 +3,7 @@
|
|||||||
# Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
|
# Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
|
||||||
# URL: https://github.com/gryf/vboxmanage-bash-completion
|
# URL: https://github.com/gryf/vboxmanage-bash-completion
|
||||||
# License: 3-clause BSD-style license (see LICENSE file)
|
# License: 3-clause BSD-style license (see LICENSE file)
|
||||||
# Version: 7.1.8
|
# Version: 7.2.4
|
||||||
|
|
||||||
|
|
||||||
_VBoxManage() {
|
_VBoxManage() {
|
||||||
@@ -474,6 +474,24 @@ _VBoxManage() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_iface_comp() {
|
||||||
|
local ifaces
|
||||||
|
local item
|
||||||
|
ifaces=$(VBoxManage objtracker ifaces | \
|
||||||
|
grep -v "Supported interfaces:" | \
|
||||||
|
$VBMC_SED 's/^\s\+//g' | \
|
||||||
|
$VBMC_SED 's/\s\+$//g' | \
|
||||||
|
tr '\n' '|' | \
|
||||||
|
$VBMC_SED 's/|$//')
|
||||||
|
IFS='|' read -ra ifaces <<< "$ifaces"
|
||||||
|
|
||||||
|
for item in "${ifaces[@]}"
|
||||||
|
do
|
||||||
|
[[ ${item^^} == ${cur^^}* ]] && COMPREPLY+=("$item")
|
||||||
|
done
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
COMP_WORDBREAKS=${COMP_WORDBREAKS//|/} # remove pipe from comp word breaks
|
COMP_WORDBREAKS=${COMP_WORDBREAKS//|/} # remove pipe from comp word breaks
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
|
|
||||||
@@ -2025,7 +2043,7 @@ _VBoxManage() {
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
modifyvm)
|
modifyvm)
|
||||||
items=(--accelerate-2d-video --accelerate-3d --acpi --apic --audio
|
items=(--accelerate-3d --acpi --apic --arm-gic-its --audio
|
||||||
--audio-codec --audio-controller --audio-in --audio-out
|
--audio-codec --audio-controller --audio-in --audio-out
|
||||||
--autostart-delay --autostart-enabled --boot1 --boot2 --boot3
|
--autostart-delay --autostart-enabled --boot1 --boot2 --boot3
|
||||||
--boot4 --bridge-adapter1 --bridge-adapter2 --bridge-adapter3
|
--boot4 --bridge-adapter1 --bridge-adapter2 --bridge-adapter3
|
||||||
@@ -2058,22 +2076,20 @@ _VBoxManage() {
|
|||||||
--lpt-mode1 --lpt1 --mac-address1 --mac-address2 --mac-address3
|
--lpt-mode1 --lpt1 --mac-address1 --mac-address2 --mac-address3
|
||||||
--mac-address4 --mac-address5 --mac-address6 --mac-address7
|
--mac-address4 --mac-address5 --mac-address6 --mac-address7
|
||||||
--mac-address8 --mds-clear-on-sched --mds-clear-on-vm-entry
|
--mac-address8 --mds-clear-on-sched --mds-clear-on-vm-entry
|
||||||
--memory --monitor-count --mouse --name --nat-alias-mode1
|
--memory --monitor-count --mouse --name --nat-bind-ip1
|
||||||
--nat-alias-mode2 --nat-alias-mode3 --nat-alias-mode4
|
--nat-bind-ip2 --nat-bind-ip3 --nat-bind-ip4 --nat-bind-ip5
|
||||||
--nat-alias-mode5 --nat-alias-mode6 --nat-alias-mode7
|
--nat-bind-ip6 --nat-bind-ip7 --nat-bind-ip8
|
||||||
--nat-alias-mode8 --nat-bind-ip1 --nat-bind-ip2 --nat-bind-ip3
|
|
||||||
--nat-bind-ip4 --nat-bind-ip5 --nat-bind-ip6 --nat-bind-ip7
|
|
||||||
--nat-bind-ip8 --nat-dns-host-resolver1 --nat-dns-host-resolver2
|
|
||||||
--nat-dns-host-resolver3 --nat-dns-host-resolver4
|
|
||||||
--nat-dns-host-resolver5 --nat-dns-host-resolver6
|
|
||||||
--nat-dns-host-resolver7 --nat-dns-host-resolver8
|
|
||||||
--nat-dns-pass-domain1 --nat-dns-pass-domain2
|
--nat-dns-pass-domain1 --nat-dns-pass-domain2
|
||||||
--nat-dns-pass-domain3 --nat-dns-pass-domain4
|
--nat-dns-pass-domain3 --nat-dns-pass-domain4
|
||||||
--nat-dns-pass-domain5 --nat-dns-pass-domain6
|
--nat-dns-pass-domain5 --nat-dns-pass-domain6
|
||||||
--nat-dns-pass-domain7 --nat-dns-pass-domain8 --nat-dns-proxy1
|
--nat-dns-pass-domain7 --nat-dns-pass-domain8 --nat-enable-tftp1
|
||||||
--nat-dns-proxy2 --nat-dns-proxy3 --nat-dns-proxy4
|
--nat-enable-tftp2 --nat-enable-tftp3 --nat-enable-tftp4
|
||||||
--nat-dns-proxy5 --nat-dns-proxy6 --nat-dns-proxy7
|
--nat-enable-tftp5 --nat-enable-tftp6 --nat-enable-tftp7
|
||||||
--nat-dns-proxy8 --nat-localhostreachable1
|
--nat-enable-tftp8 --nat-forward-broadcast1
|
||||||
|
--nat-forward-broadcast2 --nat-forward-broadcast3
|
||||||
|
--nat-forward-broadcast4 --nat-forward-broadcast5
|
||||||
|
--nat-forward-broadcast6 --nat-forward-broadcast7
|
||||||
|
--nat-forward-broadcast8 --nat-localhostreachable1
|
||||||
--nat-localhostreachable2 --nat-localhostreachable3
|
--nat-localhostreachable2 --nat-localhostreachable3
|
||||||
--nat-localhostreachable4 --nat-localhostreachable5
|
--nat-localhostreachable4 --nat-localhostreachable5
|
||||||
--nat-localhostreachable6 --nat-localhostreachable7
|
--nat-localhostreachable6 --nat-localhostreachable7
|
||||||
@@ -2146,23 +2162,23 @@ _VBoxManage() {
|
|||||||
_os_comp
|
_os_comp
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--accelerate-2d-video|--accelerate-3d|--acpi|--apic|\
|
--accelerate-3d|--acpi|--apic|--arm-gic-its|--audio-in|\
|
||||||
--audio-in|--audio-out|--autostart-enabled|\
|
--audio-out|--autostart-enabled|--cable-connected1|\
|
||||||
--cable-connected1|--cable-connected2|--cable-connected3|\
|
--cable-connected2|--cable-connected3|--cable-connected4|\
|
||||||
--cable-connected4|--cable-connected5|--cable-connected6|\
|
--cable-connected5|--cable-connected6|--cable-connected7|\
|
||||||
--cable-connected7|--cable-connected8|--cpu-hotplug|\
|
--cable-connected8|--cpu-hotplug|--firmware-logo-fade-in|\
|
||||||
--firmware-logo-fade-in|--firmware-logo-fade-out|\
|
--firmware-logo-fade-out|--firmware-pxe-debug|--hwvirtex|\
|
||||||
--firmware-pxe-debug|--hwvirtex|--ibpb-on-vm-entry|\
|
--ibpb-on-vm-entry|--ibpb-on-vm-exit|--ioapic|\
|
||||||
--ibpb-on-vm-exit|--ioapic|--l1d-flush-on-sched|\
|
--l1d-flush-on-sched|--l1d-flush-on-vm-entry|--large-pages|\
|
||||||
--l1d-flush-on-vm-entry|--large-pages|--mds-clear-on-sched|\
|
--mds-clear-on-sched|--mds-clear-on-vm-entry|\
|
||||||
--mds-clear-on-vm-entry|--nat-dns-host-resolver[1-8]|\
|
--nat-dns-pass-domain[1-8]|--nat-enable-tftp[1-8]|\
|
||||||
--nat-dns-pass-domain[1-8]|--nat-dns-proxy[1-8]|\
|
--nat-forward-broadcast[1-8]|--nat-localhostreachable[1-8]|\
|
||||||
--nat-localhostreachable[1-8]|--nested-hw-virt|\
|
--nested-hw-virt|--nested-paging|--nic-trace[1-8]|\
|
||||||
--nested-paging|--nic-trace[1-8]|--page-fusion|--recording|\
|
--page-fusion|--recording|--rtc-use-utc|--spec-ctrl|\
|
||||||
--rtc-use-utc|--spec-ctrl|--system-uuid-le|--teleporter|\
|
--system-uuid-le|--teleporter|--testing-enabled|\
|
||||||
--testing-enabled|--testing-mmio|--tracing-allow-vm-access|\
|
--testing-mmio|--tracing-allow-vm-access|--tracing-enabled|\
|
||||||
--tracing-enabled|--triple-fault-reset|--usb-card-reader|\
|
--triple-fault-reset|--usb-card-reader|--usb-ehci|\
|
||||||
--usb-ehci|--usb-ohci|--usb-xhci|--virt-vmsave-vmload|--vrde|\
|
--usb-ohci|--usb-xhci|--virt-vmsave-vmload|--vrde|\
|
||||||
--vrde-multi-con|--vrde-reuse-con|--vrde-video-channel|\
|
--vrde-multi-con|--vrde-reuse-con|--vrde-video-channel|\
|
||||||
--x86-hpet|--x86-long-mode|--x86-pae|--x86-vtx-ux|\
|
--x86-hpet|--x86-long-mode|--x86-pae|--x86-vtx-ux|\
|
||||||
--x86-vtx-vpid|--x86-x2apic)
|
--x86-vtx-vpid|--x86-x2apic)
|
||||||
@@ -2206,7 +2222,7 @@ _VBoxManage() {
|
|||||||
|
|
||||||
--nic-type[1-8])
|
--nic-type[1-8])
|
||||||
COMPREPLY=( $(compgen -W "Am79C970A Am79C973 82540EM
|
COMPREPLY=( $(compgen -W "Am79C970A Am79C973 82540EM
|
||||||
82543GC 82545EM virtio" -- ${cur}) )
|
82543GC 82545EM virtio usbnet" -- ${cur}) )
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--nic-promisc[1-8])
|
--nic-promisc[1-8])
|
||||||
@@ -2254,10 +2270,6 @@ _VBoxManage() {
|
|||||||
COMPREPLY=( $(compgen -W "delete" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "delete" -- ${cur}) )
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--nat-alias-mode[1-8])
|
|
||||||
COMPREPLY=( $(compgen -W "default" -- ${cur}) )
|
|
||||||
;;
|
|
||||||
|
|
||||||
--macaddress[1-8])
|
--macaddress[1-8])
|
||||||
COMPREPLY=( $(compgen -W "auto" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "auto" -- ${cur}) )
|
||||||
;;
|
;;
|
||||||
@@ -2456,6 +2468,27 @@ _VBoxManage() {
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
objtracker)
|
||||||
|
items=(ifaces objlist objinfo)
|
||||||
|
case "${prev}" in
|
||||||
|
objlist)
|
||||||
|
items=(--ifacename)
|
||||||
|
_get_excluded_items "${items[@]}"
|
||||||
|
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
objinfo)
|
||||||
|
items=(--ifacename --id)
|
||||||
|
_get_excluded_items "${items[@]}"
|
||||||
|
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
--ifacename)
|
||||||
|
_iface_comp
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
[[ ${#COMPREPLY[@]} -eq 0 ]] && \
|
||||||
|
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
|
||||||
registervm)
|
registervm)
|
||||||
if [[ ${prev} == ${cmd} ]]; then
|
if [[ ${prev} == ${cmd} ]]; then
|
||||||
bind 'set mark-directories on'
|
bind 'set mark-directories on'
|
||||||
@@ -2524,7 +2557,11 @@ _VBoxManage() {
|
|||||||
items=(add remove modify)
|
items=(add remove modify)
|
||||||
subcommand=${COMP_WORDS[2]}
|
subcommand=${COMP_WORDS[2]}
|
||||||
case "${prev}" in
|
case "${prev}" in
|
||||||
add|remove|modify)
|
add|remove)
|
||||||
|
_vms_comp vms
|
||||||
|
COMPREPLY+=( "global" )
|
||||||
|
;;
|
||||||
|
modify)
|
||||||
_vms_comp vms
|
_vms_comp vms
|
||||||
;;
|
;;
|
||||||
--hostpath)
|
--hostpath)
|
||||||
@@ -2798,7 +2835,8 @@ _VBoxManage() {
|
|||||||
COMPREPLY=( $(compgen -W "detect install" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "detect install" -- ${cur}) )
|
||||||
else
|
else
|
||||||
case "${prev}" in
|
case "${prev}" in
|
||||||
--iso|--password-file|--additions-iso|--validation-kit-iso|\
|
--admin-password-file|--iso|--user-password-file|\
|
||||||
|
--additions-iso|--validation-kit-iso|\
|
||||||
--script-template|--post-install-template)
|
--script-template|--post-install-template)
|
||||||
COMPREPLY+=( $(compgen -f -- ${cur}) )
|
COMPREPLY+=( $(compgen -f -- ${cur}) )
|
||||||
;;
|
;;
|
||||||
@@ -2822,7 +2860,7 @@ _VBoxManage() {
|
|||||||
if [[ ${prev} == ${subcommand} ]]; then
|
if [[ ${prev} == ${subcommand} ]]; then
|
||||||
_vms_comp vms
|
_vms_comp vms
|
||||||
else
|
else
|
||||||
local items=(--additions-iso --admin-password
|
local items=(--additions-iso
|
||||||
--auxiliary-base-path --country --dry-run
|
--auxiliary-base-path --country --dry-run
|
||||||
--extra-install-kernel-parameters
|
--extra-install-kernel-parameters
|
||||||
--full-user-name --hostname --image-index
|
--full-user-name --hostname --image-index
|
||||||
@@ -2830,17 +2868,23 @@ _VBoxManage() {
|
|||||||
--key --language --locale
|
--key --language --locale
|
||||||
--no-install-additions --no-install-txs
|
--no-install-additions --no-install-txs
|
||||||
--package-selection-adjustment
|
--package-selection-adjustment
|
||||||
--password-file --post-install-command
|
--post-install-command
|
||||||
--post-install-template --script-template
|
--post-install-template --proxy
|
||||||
--start-vm --time-zone --user
|
--script-template --start-vm --time-zone
|
||||||
--user-password --validation-kit-iso)
|
--user --validation-kit-iso)
|
||||||
_get_excluded_items "${items[@]}"
|
|
||||||
|
[[ " ${COMP_WORDS[*]} " != *" --admin-password "* &&
|
||||||
|
" ${COMP_WORDS[*]} " != *" --admin-password-file"* ]] &&
|
||||||
|
items+=( --admin-password-file --admin-password )
|
||||||
|
[[ " ${COMP_WORDS[*]} " != *" --user-password "* &&
|
||||||
|
" ${COMP_WORDS[*]} " != *" --user-password-file"* ]] &&
|
||||||
|
items+=( --user-password-file --user-password )
|
||||||
|
|
||||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -2949,7 +2993,6 @@ _VBoxManage() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
complete -o default -F _VBoxManage VBoxManage
|
complete -o default -F _VBoxManage VBoxManage
|
||||||
|
|||||||
Reference in New Issue
Block a user