mirror of
https://github.com/gryf/vboxmanage-bash-completion.git
synced 2025-12-19 20:38:05 +01:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 11a0844c4d | |||
| 9b06c430fd | |||
| fbdd259cac | |||
| d79a8bc280 | |||
| 20b1ef9fab | |||
| 1674acbe92 | |||
| 9b7ab10421 | |||
| 47e3ff6bbe | |||
| f81bfe514f | |||
| a78a03286a | |||
| 04fba0a65a |
@@ -6,7 +6,7 @@ script. However, in some point of time I've decided to rewrite it almost from
|
||||
scratch.
|
||||
|
||||
Current version of script was written and tested against VBoxManage in version
|
||||
5.0.32, and supports all commands (in some extent ;)).
|
||||
5.1.32, and supports all commands (in some extent ;)).
|
||||
|
||||
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:
|
||||
|
||||
118
VBoxManage
118
VBoxManage
@@ -1,9 +1,10 @@
|
||||
# bash command-line completion for VBoxManage command
|
||||
#
|
||||
# Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
|
||||
# URL: https://bitbucket.org/gryf/vboxmanage-bash-completion
|
||||
# URL: https://bitbucket.org/gryf/vboxmanage-bash-completion
|
||||
# URL: https://github.com/gryf/vboxmanage-bash-completion
|
||||
# License: 3-clause BSD-style license (see LICENSE file)
|
||||
# Version: 5.1.32
|
||||
|
||||
_VBoxManage() {
|
||||
local cur prev opts cmd subcommand tmp items name index result
|
||||
@@ -440,6 +441,10 @@ _VBoxManage() {
|
||||
sort | \
|
||||
uniq)
|
||||
|
||||
# add debugvm command manually, since it's described differently in
|
||||
# vboxmanage help
|
||||
opts="${opts} debugvm"
|
||||
|
||||
if [[ ${cur} == "-q" || ${COMP_CWORD} -eq 1 ]] ; then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
@@ -499,6 +504,7 @@ _VBoxManage() {
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
checkmediumpwd)
|
||||
if [[ ${prev} == ${cmd} ]]; then
|
||||
_hdd_comp
|
||||
@@ -625,7 +631,6 @@ _VBoxManage() {
|
||||
videocapmaxtime videocapmaxsize addencpassword removeencpassword
|
||||
removeallencpasswords)
|
||||
|
||||
|
||||
_find_item_name 2
|
||||
subcommand=${COMP_WORDS[$((index+1))]}
|
||||
|
||||
@@ -702,11 +707,9 @@ _VBoxManage() {
|
||||
_get_excluded_items "${tmp[@]}"
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
;;
|
||||
|
||||
--removeonsuspend)
|
||||
COMPREPLY=( $(compgen -W "yes no" -- ${cur}) )
|
||||
;;
|
||||
|
||||
addencpassword)
|
||||
tmp=(--host --port --maxdowntime --passwordfile
|
||||
--password)
|
||||
@@ -807,9 +810,9 @@ _VBoxManage() {
|
||||
fi
|
||||
;;
|
||||
|
||||
debugvm)
|
||||
"debugvm")
|
||||
items=(dumpguestcore info injectnmi log logdest logflags osdetect
|
||||
osinfo osdmesg getregisters setregisters show statistics)
|
||||
osinfo osdmesg getregisters setregisters show statistics stack)
|
||||
if [[ ${prev} == ${cmd} ]]; then
|
||||
_vms_comp runningvms
|
||||
else
|
||||
@@ -826,7 +829,7 @@ _VBoxManage() {
|
||||
_get_excluded_items "${items[@]}"
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
;;
|
||||
getregisters|setregisters)
|
||||
getregisters|setregisters|stack)
|
||||
_get_excluded_items "--cpu"
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
;;
|
||||
@@ -837,7 +840,7 @@ _VBoxManage() {
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
;;
|
||||
statistics)
|
||||
items=(--reset --pattern)
|
||||
items=(--reset --pattern --descriptions)
|
||||
_get_excluded_items "${items[@]}"
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
;;
|
||||
@@ -850,7 +853,6 @@ _VBoxManage() {
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
;;
|
||||
esac
|
||||
_get_excluded_items "--descriptions"
|
||||
COMPREPLY+=( $(compgen -W "$result" -- ${cur}) )
|
||||
else
|
||||
[[ "${prev}" == "--filename" ]] && \
|
||||
@@ -921,7 +923,6 @@ _VBoxManage() {
|
||||
else
|
||||
COMPREPLY=( $(compgen -W "--newpassword --oldpassword --cipher
|
||||
--newpasswordid" -- ${cur}) )
|
||||
|
||||
fi
|
||||
;;
|
||||
|
||||
@@ -992,10 +993,10 @@ _VBoxManage() {
|
||||
;;
|
||||
|
||||
guestcontrol)
|
||||
local items=(run start copyfrom copyto mkdir createdir
|
||||
createdirectory rmdir removedir removedirectory removefile rm mv
|
||||
move ren rename mktemp createtemp createtemporary stat list
|
||||
closeprocess closesession updatega updateguestadditions
|
||||
local items=(run start copyfrom copyto mkdir createdir
|
||||
createdirectory rmdir removedir removedirectory removefile rm mv
|
||||
move ren rename mktemp createtemp createtemporary stat list
|
||||
closeprocess closesession updatega updateguestadditions
|
||||
updateadditions watch)
|
||||
|
||||
if [[ ${prev} == ${cmd} ]]; then
|
||||
@@ -1007,7 +1008,7 @@ _VBoxManage() {
|
||||
case "${subcommand}" in
|
||||
run)
|
||||
items=(--exe --timeout --unquoted-args
|
||||
--ignore-operhaned-processes --no-profile
|
||||
--ignore-operhaned-processes --profile
|
||||
--dos2unix --unix2dos --username --domain --)
|
||||
|
||||
[[ " ${comp_words[@]} " != *" --password "* ||
|
||||
@@ -1035,7 +1036,7 @@ _VBoxManage() {
|
||||
|
||||
start)
|
||||
items=(--exe --timeout --unquoted-args
|
||||
--ignore-operhaned-processes --no-profile
|
||||
--ignore-operhaned-processes --profile
|
||||
--username --domain --passwordfile --password --)
|
||||
|
||||
[[ " ${comp_words[@]} " != *" --password "* ||
|
||||
@@ -1246,6 +1247,7 @@ _VBoxManage() {
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
fi
|
||||
;;
|
||||
|
||||
updatega|updateguestadditions|updateadditions)
|
||||
items=(--source --wait-start)
|
||||
[[ " ${COMP_WORDS[@]} " != *" --verbose "* &&
|
||||
@@ -1258,6 +1260,7 @@ _VBoxManage() {
|
||||
_get_excluded_items "${items[@]}"
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
;;
|
||||
|
||||
watch)
|
||||
items=()
|
||||
[[ " ${COMP_WORDS[@]} " != *" --verbose "* &&
|
||||
@@ -1271,6 +1274,7 @@ _VBoxManage() {
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
;;
|
||||
esac
|
||||
|
||||
case "${prev}" in
|
||||
close)
|
||||
items=(--verbose)
|
||||
@@ -1469,14 +1473,12 @@ _VBoxManage() {
|
||||
_get_excluded_items "${items[@]}"
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
fi
|
||||
|
||||
;;
|
||||
esac
|
||||
else
|
||||
[[ ${#COMPREPLY[@]} -eq 0 ]] && \
|
||||
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
|
||||
fi
|
||||
|
||||
;;
|
||||
|
||||
modifymedium)
|
||||
@@ -1495,7 +1497,8 @@ _VBoxManage() {
|
||||
;;
|
||||
*)
|
||||
_find_item_name 2
|
||||
items=(--type --autoreset --property --compact --resize)
|
||||
items=(--type --autoreset --property --compact --resize
|
||||
--move)
|
||||
_get_excluded_items "${items[@]}"
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
case "${prev}" in
|
||||
@@ -1507,6 +1510,9 @@ _VBoxManage() {
|
||||
--autoreset)
|
||||
COMPREPLY=( $(compgen -W "on off" -- ${cur}) )
|
||||
;;
|
||||
--move)
|
||||
COMPREPLY=( $(compgen -o dirnames -- ${cur}) )
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
@@ -1585,7 +1591,8 @@ _VBoxManage() {
|
||||
--videocapfile --videocapres --videocaprate --videocapfps
|
||||
--videocapmaxtime --videocapmaxsize --videocapopts --defaultfrontend
|
||||
--cpuid-portability-level --paravirtprovider --audiocodec --usbxhci
|
||||
--usbrename)
|
||||
--usbrename --apic --x2apic --paravirtdebug --cpu-profile
|
||||
--biosapic --videocapopts --ibpb-on-vm-entry --ibpb-on-vm-exit)
|
||||
|
||||
if [[ ${prev} == ${cmd} ]]; then
|
||||
_vms_comp vms
|
||||
@@ -1597,10 +1604,12 @@ _VBoxManage() {
|
||||
COMPREPLY=()
|
||||
_group_comp
|
||||
;;
|
||||
|
||||
--ostype)
|
||||
COMPREPLY=()
|
||||
_os_comp
|
||||
;;
|
||||
|
||||
--pagefusion|--acpi|--ioapic|--hpet|--triplefaultreset|\
|
||||
--hwvirtex|--nestedpaging|--largepages|--vtxvpid|--vtxux|\
|
||||
--pae|--longmode|--cpuhotplug|--rtcuseutc|\
|
||||
@@ -1622,73 +1631,90 @@ _VBoxManage() {
|
||||
--vrdemulticon|--vrdereusecon|--vrdevideochannel|--usb|\
|
||||
--usbehci|--teleporter|--tracing-enabled|\
|
||||
--tracing-allow-vm-access|--usbcardreader|\
|
||||
--autostart-enabled|--videocap|--usbxhci)
|
||||
--autostart-enabled|--videocap|--usbxhci|--apic|--x2apic|\
|
||||
--ibpb-on-vm-entry|--ibpb-on-vm-exit)
|
||||
COMPREPLY=( $(compgen -W "on off" -- ${cur}) )
|
||||
;;
|
||||
|
||||
--graphicscontroller)
|
||||
COMPREPLY=( $(compgen -W "none vboxvga vmsvga" \
|
||||
-- ${cur}) )
|
||||
;;
|
||||
|
||||
--firmware)
|
||||
COMPREPLY=( $(compgen -W "bios efi efi32 efi64" \
|
||||
-- ${cur}) )
|
||||
;;
|
||||
|
||||
--chipset)
|
||||
COMPREPLY=( $(compgen -W "ich9 piix3" -- ${cur}) )
|
||||
;;
|
||||
|
||||
--biosbootmenu)
|
||||
COMPREPLY=( $(compgen -W "disabled menuonly
|
||||
messageandmenu" -- ${cur}) )
|
||||
;;
|
||||
|
||||
--boot[1-4])
|
||||
COMPREPLY=( $(compgen -W "none floppy dvd disk net" \
|
||||
-- ${cur}) )
|
||||
;;
|
||||
|
||||
--nic[1-8])
|
||||
COMPREPLY=( $(compgen -W "none null nat bridged intnet
|
||||
hostonly generic natnetwork" -- ${cur}) )
|
||||
;;
|
||||
|
||||
--nictype[1-8])
|
||||
COMPREPLY=( $(compgen -W "Am79C970A Am79C973 82540EM
|
||||
82543GC 82545EM virtio" -- ${cur}) )
|
||||
;;
|
||||
|
||||
--nicpromisc[1-8])
|
||||
COMPREPLY=( $(compgen -W "deny allow-vms allow-all" \
|
||||
-- ${cur}) )
|
||||
;;
|
||||
|
||||
--nicbandwidthgroup[1-8])
|
||||
COMPREPLY=()
|
||||
_bandwidthctl_comp
|
||||
_get_excluded_items "none"
|
||||
COMPREPLY+=( $(compgen -W "$result" -- ${cur}) )
|
||||
;;
|
||||
|
||||
--bridgeadapter[1-8])
|
||||
COMPREPLY=()
|
||||
_bridgedif_comp
|
||||
_get_excluded_items "none"
|
||||
COMPREPLY+=( $(compgen -W "$result" -- ${cur}) )
|
||||
;;
|
||||
|
||||
--hostonlyadapter[1-8])
|
||||
COMPREPLY=()
|
||||
_hostonlyif_comp
|
||||
_get_excluded_items "none"
|
||||
COMPREPLY+=( $(compgen -W "$result" -- ${cur}) )
|
||||
;;
|
||||
|
||||
--intnet[1-8])
|
||||
COMPREPLY=()
|
||||
_intnet_comp
|
||||
;;
|
||||
|
||||
--nat-network[1-8])
|
||||
COMPREPLY=()
|
||||
_natnet_comp
|
||||
;;
|
||||
|
||||
--natnet[1-8])
|
||||
COMPREPLY=()
|
||||
_natnet_comp
|
||||
;;
|
||||
|
||||
--natpf[1-8])
|
||||
COMPREPLY+=( $(compgen -W "delete" -- ${cur}) )
|
||||
;;
|
||||
|
||||
--nataliasmode[1-8])
|
||||
COMPREPLY+=( $(compgen -W "default" -- ${cur}) )
|
||||
;;
|
||||
@@ -1696,10 +1722,12 @@ _VBoxManage() {
|
||||
--macaddress[1-8])
|
||||
COMPREPLY+=( $(compgen -W "auto" -- ${cur}) )
|
||||
;;
|
||||
|
||||
--mouse)
|
||||
COMPREPLY+=( $(compgen -W "ps2 usb usbtablet
|
||||
usbmultitouch" -- ${cur}) )
|
||||
;;
|
||||
|
||||
--keyboard)
|
||||
COMPREPLY+=( $(compgen -W "ps2 usb" -- ${cur}) )
|
||||
;;
|
||||
@@ -1707,10 +1735,12 @@ _VBoxManage() {
|
||||
--uart[1-2]|--lpt[1-2])
|
||||
COMPREPLY+=( $(compgen -W "off" -- ${cur}) )
|
||||
;;
|
||||
|
||||
--uartmode[1-2])
|
||||
COMPREPLY+=( $(compgen -W "disconnected server client
|
||||
tcpserver tcpclient file" -- ${cur}) )
|
||||
;;
|
||||
|
||||
--audio)
|
||||
COMPREPLY+=( $(compgen -W "none null oss alsa pulse" \
|
||||
-- ${cur}) )
|
||||
@@ -1729,6 +1759,7 @@ _VBoxManage() {
|
||||
COMPREPLY+=( $(compgen -W "disabled hosttoguest
|
||||
guesttohost bidirectional" -- ${cur}) )
|
||||
;;
|
||||
|
||||
--draganddrop)
|
||||
COMPREPLY+=( $(compgen -W "disabled hosttoguest" \
|
||||
-- ${cur}) )
|
||||
@@ -1738,23 +1769,36 @@ _VBoxManage() {
|
||||
--defaultfrontend)
|
||||
COMPREPLY+=( $(compgen -W "default" -- ${cur}) )
|
||||
;;
|
||||
|
||||
--vrdeauthtype)
|
||||
COMPREPLY+=( $(compgen -W "null external guest" \
|
||||
-- ${cur}) )
|
||||
;;
|
||||
|
||||
--paravirtprovider)
|
||||
COMPREPLY=( $(compgen -W "none default legacy minimal
|
||||
hyperv kvm" -- ${cur}) )
|
||||
;;
|
||||
|
||||
--cpuid-portability-level)
|
||||
COMPREPLY=( $(compgen -W "0 1 2 3" -- ${cur}) )
|
||||
;;
|
||||
|
||||
--cpu-profile)
|
||||
COMPREPLY=( $(compgen -W "host 8086 80286 80386" \
|
||||
-- ${cur}) )
|
||||
;;
|
||||
|
||||
--biosapic)
|
||||
COMPREPLY=( $(compgen -W "disabled apic x2apic" \
|
||||
-- ${cur}) )
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
|
||||
natnetwork)
|
||||
items=(add remove modify start stop)
|
||||
items=(add remove modify start stop list)
|
||||
subcommand=${COMP_WORDS[2]}
|
||||
if [[ "${prev}" == "--netname" ]]; then
|
||||
_natnet_comp
|
||||
@@ -1872,6 +1916,7 @@ _VBoxManage() {
|
||||
[[ ${#COMPREPLY[@]} -eq 0 ]] && \
|
||||
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
|
||||
;;
|
||||
|
||||
showmediuminfo)
|
||||
if [[ ${prev} == ${cmd} ]]; then
|
||||
COMPREPLY=( $(compgen -W "disk dvd floppy" -- ${cur}) )
|
||||
@@ -2023,11 +2068,11 @@ _VBoxManage() {
|
||||
case "${prev}" in
|
||||
--add)
|
||||
COMPREPLY=( $(compgen -W "ide sata scsi floppy
|
||||
sas" -- ${cur}) )
|
||||
sas usb pcie" -- ${cur}) )
|
||||
;;
|
||||
--controller)
|
||||
COMPREPLY=( $(compgen -W "LSILogic LSILogicSAS BusLogic
|
||||
IntelAHCI PIIX3 PIIX4 ICH6 I82078" -- ${cur}) )
|
||||
IntelAHCI PIIX3 PIIX4 ICH6 I82078 USB NVMe" -- ${cur}) )
|
||||
;;
|
||||
--bootable|--hostiocache)
|
||||
COMPREPLY=( $(compgen -W "on off" -- ${cur}) )
|
||||
@@ -2046,7 +2091,7 @@ _VBoxManage() {
|
||||
fi
|
||||
;;
|
||||
|
||||
usbfilte)
|
||||
usbfilter)
|
||||
if [[ COMP_CWORD -ge 3 ]]; then
|
||||
subcommand="${COMP_WORDS[2]}"
|
||||
if [[ $subcommand == "${cmd}" ]]; then
|
||||
@@ -2087,6 +2132,29 @@ _VBoxManage() {
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
usbdevsource)
|
||||
if [[ COMP_CWORD -ge 3 ]]; then
|
||||
subcommand="${COMP_WORDS[2]}"
|
||||
if [[ $subcommand == "${cmd}" ]]; then
|
||||
subcommand="${COMP_WORDS[3]}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ${prev} == ${cmd} ]]; then
|
||||
COMPREPLY=( $(compgen -W "add remove" -- ${cur}) )
|
||||
else
|
||||
if [[ ${#COMPREPLY[@]} -eq 0 ]]; then
|
||||
case "${subcommand}" in
|
||||
add)
|
||||
local items=(--address --backend)
|
||||
_get_excluded_items "${items[@]}"
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
complete -o default -F _VBoxManage VBoxManage
|
||||
|
||||
Reference in New Issue
Block a user