mirror of
https://github.com/gryf/vboxmanage-bash-completion.git
synced 2025-12-17 11:30:23 +01:00
Another vboxmanage commands added
This commit is contained in:
8
README
8
README
@@ -11,7 +11,15 @@ Current version of script was written and tested against VBoxManage in version
|
|||||||
- bandwidthctl
|
- bandwidthctl
|
||||||
- clonehd
|
- clonehd
|
||||||
- clonevm
|
- clonevm
|
||||||
|
- closemedium
|
||||||
- controlvm
|
- controlvm
|
||||||
|
- convertfromraw
|
||||||
- list
|
- list
|
||||||
- showhdinfo
|
- showhdinfo
|
||||||
- showvminfo
|
- showvminfo
|
||||||
|
- snapshot
|
||||||
|
- startvm
|
||||||
|
- storageattach
|
||||||
|
- storagectl
|
||||||
|
- unregistervm
|
||||||
|
- usbfilter
|
||||||
|
|||||||
187
VBoxManage
187
VBoxManage
@@ -12,9 +12,9 @@
|
|||||||
# [x] bandwidthctl
|
# [x] bandwidthctl
|
||||||
# [x] clonehd
|
# [x] clonehd
|
||||||
# [x] clonevm
|
# [x] clonevm
|
||||||
# [ ] closemedium
|
# [x] closemedium
|
||||||
# [x] controlvm
|
# [x] controlvm
|
||||||
# [ ] convertfromraw
|
# [x] convertfromraw
|
||||||
# [ ] createhd
|
# [ ] createhd
|
||||||
# [ ] createvm
|
# [ ] createvm
|
||||||
# [ ] debugvm
|
# [ ] debugvm
|
||||||
@@ -38,12 +38,12 @@
|
|||||||
# [ ] sharedfolder
|
# [ ] sharedfolder
|
||||||
# [x] showhdinfo
|
# [x] showhdinfo
|
||||||
# [x] showvminfo
|
# [x] showvminfo
|
||||||
# [ ] snapshot
|
# [x] snapshot
|
||||||
# [ ] startvm
|
# [x] startvm
|
||||||
# [ ] storageattach - no all options yet
|
# [x] storageattach
|
||||||
# [ ] storagectl
|
# [x] storagectl
|
||||||
# [ ] unregistervm
|
# [x] unregistervm
|
||||||
# [ ] usbfilter
|
# [x] usbfilter
|
||||||
|
|
||||||
_VBoxManage() {
|
_VBoxManage() {
|
||||||
local cur prev opts cmd subcommand tmp items name index result
|
local cur prev opts cmd subcommand tmp items name index result
|
||||||
@@ -223,6 +223,7 @@ _VBoxManage() {
|
|||||||
_find_item_name 2
|
_find_item_name 2
|
||||||
snap=$(VBoxManage snapshot "${name//\\/}" \
|
snap=$(VBoxManage snapshot "${name//\\/}" \
|
||||||
list | \
|
list | \
|
||||||
|
grep UUID |
|
||||||
awk -F ': ' '{print $2}' | \
|
awk -F ': ' '{print $2}' | \
|
||||||
sed 's/ (.*//' | \
|
sed 's/ (.*//' | \
|
||||||
tr '\n' '|' | \
|
tr '\n' '|' | \
|
||||||
@@ -533,6 +534,23 @@ _VBoxManage() {
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
convertfromraw)
|
convertfromraw)
|
||||||
|
local items=(--format --variant --uuid)
|
||||||
|
|
||||||
|
if [[ ${prev} == ${cmd} ]]; then
|
||||||
|
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
|
||||||
|
else
|
||||||
|
_get_excluded_items "${items[@]}"
|
||||||
|
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||||
|
case "${prev}" in
|
||||||
|
--format)
|
||||||
|
COMPREPLY=( $(compgen -W "VDI VMDK VHD" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
--variant)
|
||||||
|
COMPREPLY=( $(compgen -W "Standard Fixed Split2G Stream
|
||||||
|
ESX" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
createhd)
|
createhd)
|
||||||
;;
|
;;
|
||||||
@@ -610,16 +628,169 @@ _VBoxManage() {
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
snapshot)
|
snapshot)
|
||||||
|
items=(take delete restore restorecurrent edit list showvminfo)
|
||||||
|
if [[ ${prev} == ${cmd} ]]; then
|
||||||
|
_vms_comp vms ${cur}
|
||||||
|
else
|
||||||
|
_find_item_name 2
|
||||||
|
subcommand=${COMP_WORDS[$((index+1))]}
|
||||||
|
if [[ " ${items[@]} " == *" $subcommand "* ]]; then
|
||||||
|
case "${subcommand}" in
|
||||||
|
take)
|
||||||
|
items=(--description --live)
|
||||||
|
_get_excluded_items "${items[@]}"
|
||||||
|
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
delete|restore|showvminfo)
|
||||||
|
_snapshot_comp ${cur}
|
||||||
|
;;
|
||||||
|
restorecurrent)
|
||||||
|
COMPREPLY=()
|
||||||
|
;;
|
||||||
|
edit)
|
||||||
|
if [[ ${prev} == "edit" &&
|
||||||
|
${#COMP_WORDS[@]} == 5 ]]; then
|
||||||
|
_snapshot_comp ${cur}
|
||||||
|
COMPREPLY+=("--current")
|
||||||
|
else
|
||||||
|
items=(--name --description)
|
||||||
|
_get_excluded_items "${items[@]}"
|
||||||
|
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
list)
|
||||||
|
items=(--details --machinereadable)
|
||||||
|
_get_excluded_items "${items[@]}"
|
||||||
|
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
[[ ${#COMPREPLY[@]} -eq 0 ]] && \
|
||||||
|
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
|
||||||
|
fi
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
startvm)
|
startvm)
|
||||||
|
if [[ ${prev} == ${cmd} ]]; then
|
||||||
|
_vms_comp vms ${cur}
|
||||||
|
elif [[ "${prev}" == "--type" ]]; then
|
||||||
|
COMPREPLY=( $(compgen -W "gui sdl headless" -- ${cur}) )
|
||||||
|
else
|
||||||
|
local items=(--type)
|
||||||
|
_get_excluded_items "${items[@]}"
|
||||||
|
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
storageattach)
|
storageattach)
|
||||||
|
if [[ ${prev} == ${cmd} ]]; then
|
||||||
|
_vms_comp vms ${cur}
|
||||||
|
else
|
||||||
|
_find_item_name 2
|
||||||
|
local items=(--storagectl --port --device --type --medium --mtype
|
||||||
|
--comment --setuuid --setparentuuid --passthrough --tempeject
|
||||||
|
--nonrotational --discard --bandwidthgroup --forceunmount
|
||||||
|
--server --target --tport --lun --encodedlun --username
|
||||||
|
--password --initiator --intnet)
|
||||||
|
_get_excluded_items "${items[@]}"
|
||||||
|
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||||
|
|
||||||
|
case "${prev}" in
|
||||||
|
--type)
|
||||||
|
COMPREPLY=( $(compgen -W "dvddrive hdd fdd" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
--medium)
|
||||||
|
COMPREPLY=()
|
||||||
|
local tmp=(none emptydrive additions)
|
||||||
|
_hdd_comp ${cur}
|
||||||
|
_floppy_comp ${cur}
|
||||||
|
_dvds_comp ${cur}
|
||||||
|
for item in "${tmp[@]}"
|
||||||
|
do
|
||||||
|
[[ ${item^^} == ${cur^^}* ]] && COMPREPLY+=("$item")
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
--mtype)
|
||||||
|
COMPREPLY=( $(compgen -W "normal writethrough immutable
|
||||||
|
shareable readonly multiattach" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
--passthrough|--tempeject|--nonrotational|--discard)
|
||||||
|
COMPREPLY=( $(compgen -W "on off" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
storagectl)
|
storagectl)
|
||||||
|
local items=(--name --add --controller --portcount --hostiocache
|
||||||
|
--bootable --remove)
|
||||||
|
if [[ ${prev} == ${cmd} ]]; then
|
||||||
|
_vms_comp vms ${cur}
|
||||||
|
else
|
||||||
|
_get_excluded_items "${items[@]}"
|
||||||
|
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||||
|
case "${prev}" in
|
||||||
|
--add)
|
||||||
|
COMPREPLY=( $(compgen -W "ide sata scsi floppy
|
||||||
|
sas" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
--controller)
|
||||||
|
COMPREPLY=( $(compgen -W "LSILogic LSILogicSAS BusLogic
|
||||||
|
IntelAHCI PIIX3 PIIX4 ICH6 I82078" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
--bootable|--hostiocache)
|
||||||
|
COMPREPLY=( $(compgen -W "on off" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
unregistervm)
|
unregistervm)
|
||||||
|
if [[ ${prev} == ${cmd} ]]; then
|
||||||
|
_vms_comp vms ${cur}
|
||||||
|
else
|
||||||
|
local items=(--delete)
|
||||||
|
_get_excluded_items "${items[@]}"
|
||||||
|
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
usbfilter)
|
usbfilter)
|
||||||
|
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 modify remove" -- ${cur}) )
|
||||||
|
else
|
||||||
|
case "${prev}" in
|
||||||
|
--target)
|
||||||
|
_vms_comp vms ${cur}
|
||||||
|
COMPREPLY+=( $(compgen -W "global" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
--action)
|
||||||
|
COMPREPLY=( $(compgen -W "ignore hold" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
--active|--remote)
|
||||||
|
COMPREPLY=( $(compgen -W "yes no" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
if [[ ${#COMPREPLY[@]} -eq 0 ]]; then
|
||||||
|
case "${subcommand}" in
|
||||||
|
add|modify)
|
||||||
|
local items=(--target --name --action --active
|
||||||
|
--vendorid --productid --revision --manufacturer
|
||||||
|
--product --remote --serialnumber --maskedinterfaces)
|
||||||
|
_get_excluded_items "${items[@]}"
|
||||||
|
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
remove)
|
||||||
|
local items=(--target)
|
||||||
|
_get_excluded_items "${items[@]}"
|
||||||
|
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user