8 Commits

View File

@@ -423,7 +423,7 @@ _VBoxManage() {
# foo bar disk baz
# will search for word disk.
_get_medium () {
case "${COMP_WORDS[COMP_CWORD-2]}" in
case "${COMP_WORDS[$COMP_CWORD-2]}" in
disk)
_hdd_comp
;;
@@ -475,9 +475,9 @@ _VBoxManage() {
COMP_WORDBREAKS=${COMP_WORDBREAKS//|/} # remove pipe from comp word breaks
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [[ COMP_CWORD -ge 2 ]]; then
cur="${COMP_WORDS[$COMP_CWORD]}"
prev="${COMP_WORDS[$COMP_CWORD-1]}"
if [[ $COMP_CWORD -ge 2 ]]; then
cmd="${COMP_WORDS[1]}"
if [[ $cmd == "-q" ]]; then
cmd="${COMP_WORDS[2]}"
@@ -507,13 +507,13 @@ _VBoxManage() {
;;
bandwidthctl)
local items=(add set remove list)
local items=( add list remove set )
if [[ ${prev} == ${cmd} ]]; then
_vms_comp vms
else
_find_item_name 2
subcommand=${COMP_WORDS[$((index+1))]}
if [[ " ${items[@]} " == *" $subcommand "* ]]; then
if [[ " ${items[*]} " == *" $subcommand "* ]]; then
case "${subcommand}" in
add)
items=(--type --limit)
@@ -524,7 +524,7 @@ _VBoxManage() {
if [[ ${prev} == "set" ]]; then
_bandwidthctl_comp
else
[[ " ${COMP_WORDS[@]} " != *" --limit "* ]] && \
[[ " ${COMP_WORDS[*]} " != *" --limit "* ]] && \
COMPREPLY=( $(compgen -W "--limit" -- \
${cur}) )
fi
@@ -563,35 +563,30 @@ _VBoxManage() {
clonemedium)
if [[ ${prev} == ${cmd} ]]; then
COMPREPLY=( $(compgen -W "disk dvd floppy" -- ${cur}) )
_hdd_comp
_floppy_comp
_dvds_comp
elif [[ ${#COMP_WORDS[@]} -eq 4 ]]; then
COMPREPLY=( $(compgen -f -- ${cur}) )
else
case "${prev}" in
disk)
_hdd_comp
--format)
COMPREPLY=( $(compgen -W "VDI VMDK VHD RAW" -- ${cur}) )
;;
dvd)
_dvds_comp
;;
floppy)
_floppy_comp
--variant)
COMPREPLY=( $(compgen -W "Standard Fixed Split2G Stream
ESX" -- ${cur}) )
;;
*)
_find_item_name 2
items=(--format --variant --existing)
items=( --existing --format --variant )
[[ " ${COMP_WORDS[*]} " != *" disk "* &&
" ${COMP_WORDS[*]} " != *" dvd "* &&
" ${COMP_WORDS[*]} " != *" floppy "* ]] &&
items+=(disk dvd floppy)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
case "${prev}" in
--format)
COMPREPLY=( $(compgen -W "VDI VMDK VHD RAW" --\
${cur}) )
;;
--variant)
COMPREPLY=( $(compgen -W "Standard Fixed Split2G
Stream ESX" -- ${cur}) )
;;
esac
;;
;;
esac
fi
;;
@@ -987,11 +982,12 @@ _VBoxManage() {
;;
convertfromraw)
local items=(--format --variant --uuid)
if [[ ${prev} == ${cmd} ]]; then
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
COMPREPLY=( $(compgen -f -- ${cur}) )
elif [[ ${#COMP_WORDS[@]} -eq 4 ]]; then
COMPREPLY=( $(compgen -f -- ${cur}) )
else
items=(--format --variant --uuid)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
case "${prev}" in
@@ -1016,8 +1012,8 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
;;
*)
[[ " ${COMP_WORDS[@]} " == *" --size "* ||
" ${COMP_WORDS[@]} " == *" --sizebyte "* ]] &&
[[ " ${COMP_WORDS[*]} " == *" --size "* ||
" ${COMP_WORDS[*]} " == *" --sizebyte "* ]] &&
items=(--filename --diffparent --format --variant)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
@@ -1031,12 +1027,12 @@ _VBoxManage() {
_hdd_comp
;;
--format)
COMPREPLY=( $(compgen -W "VDI VMDK VHD" --\
${cur}) )
COMPREPLY=( $(compgen -W "VDI VMDK VHD" \
-- ${cur}) )
;;
--variant)
COMPREPLY=( $(compgen -W "Standard Fixed Split2G
Stream ESX Formatted" -- ${cur}) )
Stream ESX Formatted RawDisk" -- ${cur}) )
;;
esac
;;
@@ -1744,7 +1740,7 @@ _VBoxManage() {
if [[ "${prev}" == "${subcommand}" ]]; then
_vms_comp vms
elif [[ " ${items[@]} " == *" $subcommand "* ]]; then
elif [[ " ${items[*]} " == *" $subcommand "* ]]; then
case "${subcommand}" in
get)
_get_excluded_items "--verbose"
@@ -1755,7 +1751,8 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
enumerate)
_get_excluded_items "--patterns"
_get_excluded_items "--no-timestamp --no-flags --relative
--old-format"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
wait)
@@ -1919,7 +1916,7 @@ _VBoxManage() {
disk|dvd|floppy)
COMPREPLY=( $(compgen -W "get set delete" -- ${cur}) )
;;
get|set|floppy)
get|set|delete)
_get_medium
;;
esac
@@ -2740,17 +2737,21 @@ _VBoxManage() {
_vms_comp vms
else
_find_item_name 2
local items=(--storagectl --port --device --type --medium --mtype
--comment --setuuid --setparentuuid --passthrough --tempeject
--nonrotational --discard --hotpluggable --bandwidthgroup
--forceunmount --server --target --tport --lun --encodedlun
--username --password --initiator --intnet --passwordfile)
local items=( --bandwidthgroup --comment --device --discard
--encodedlun --forceunmount --hotpluggable --initiator --intnet
--lun --medium --mtype --nonrotational --passthrough --password
--passwordfile --port --server --setparentuuid --setuuid
--storagectl --target --tempeject --tport --type --username )
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
case "${prev}" in
--type)
COMPREPLY=( $(compgen -W "dvddrive hdd fdd" -- ${cur}) )
--bandwidthgroup)
COMPREPLY=( $(compgen -W "none" -- ${cur}) )
;;
--discard|--hotpluggable|--nonrotational|--passthrough|\
--tempeject)
COMPREPLY=( $(compgen -W "on off" -- ${cur}) )
;;
--medium)
COMPREPLY=()
@@ -2767,19 +2768,19 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "normal writethrough immutable
shareable readonly multiattach" -- ${cur}) )
;;
--passthrough|--tempeject|--nonrotational|--discard)
COMPREPLY=( $(compgen -W "on off" -- ${cur}) )
;;
--passwordfile)
COMPREPLY=( $(compgen -f -- ${cur}) )
;;
--type)
COMPREPLY=( $(compgen -W "dvddrive hdd fdd" -- ${cur}) )
;;
esac
fi
;;
storagectl)
local items=(--name --add --controller --portcount --hostiocache
--bootable --rename --remove)
local items=( --add --bootable --controller --hostiocache --name
--portcount --remove --rename )
if [[ ${prev} == ${cmd} ]]; then
_vms_comp vms
else
@@ -2787,12 +2788,13 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
case "${prev}" in
--add)
COMPREPLY=( $(compgen -W "ide sata scsi floppy
sas usb pcie" -- ${cur}) )
COMPREPLY=( $(compgen -W "floppy ide pcie sas sata scsi
usb" -- ${cur}) )
;;
--controller)
COMPREPLY=( $(compgen -W "LSILogic LSILogicSAS BusLogic
IntelAHCI PIIX3 PIIX4 ICH6 I82078 USB NVMe" -- ${cur}) )
COMPREPLY=( $(compgen -W "BusLogic I82078 ICH6 IntelAhci
LSILogic LSILogicSAS NVMe PIIX3 PIIX4 USB VirtIO" \
-- ${cur}) )
;;
--bootable|--hostiocache)
COMPREPLY=( $(compgen -W "on off" -- ${cur}) )
@@ -2802,7 +2804,7 @@ _VBoxManage() {
;;
unattended)
if [[ COMP_CWORD -ge 3 ]]; then
if [[ $COMP_CWORD -ge 3 ]]; then
subcommand="${COMP_WORDS[2]}"
if [[ $subcommand == "${cmd}" ]]; then
subcommand="${COMP_WORDS[3]}"
@@ -2899,7 +2901,7 @@ _VBoxManage() {
;;
usbdevsource)
if [[ COMP_CWORD -ge 3 ]]; then
if [[ $COMP_CWORD -ge 3 ]]; then
subcommand="${COMP_WORDS[2]}"
if [[ $subcommand == "${cmd}" ]]; then
subcommand="${COMP_WORDS[3]}"
@@ -2922,7 +2924,7 @@ _VBoxManage() {
;;
usbfilter)
if [[ COMP_CWORD -ge 3 ]]; then
if [[ $COMP_CWORD -ge 3 ]]; then
subcommand="${COMP_WORDS[2]}"
if [[ $subcommand == "${cmd}" ]]; then
subcommand="${COMP_WORDS[3]}"