11 Commits

Author SHA1 Message Date
1be3e589d4 Bump to 5.2.32 version 2019-09-16 07:24:42 +02:00
9c5b048c62 Bump to 5.2.26
Added guesttohost and bidirectional parameters for --draganddrop option
for both: controlvm and modifyvm.
2019-04-23 19:14:39 +02:00
5fd18d7cec Removed redundant --videocapopts from modifyvm 2019-04-23 19:14:39 +02:00
05af06f337 Merge pull request #7 from schplurtz/comp_words
change comp_words to upper case
2019-02-19 19:21:21 +01:00
cde78c8e4c Merge pull request #6 from schplurtz/snaplist
handle snapshot completion entirely with awk
2019-02-19 19:19:39 +01:00
Schplurtz le Déboulonné
197c46cd35 change comp_words to upper case 2019-02-19 10:58:37 +01:00
Christophe Martin
296be19560 handle snapshot completion entirely with awk
fixes #5
Also list and complete snapshot uuid.
2019-02-19 10:41:23 +01:00
62f57ebbb7 Added level 1 data cache options.
New options are added to modifyvm command:
- --l1d-flush-on-sched
- --l1d-flush-on-vm-entry
2018-11-28 20:21:06 +01:00
d4f56a0d6b Added unattended command. 2018-09-09 15:58:14 +02:00
f8b5981935 Corrected file/dir completions. 2018-09-08 17:41:02 +02:00
d027094e7c Added new options for commands.
In version 5.2.14 of VirtualBox, new options for following commands has
been added. Adjusted completion accordingly.

- list (-s|--sorted)
- modifyvm (--cpiudset -> --cpuid-set, --cpuidremove -> --cpuid-remove,
  --audioin, --audioout)
- export (new file format choice: --opc10)
- startvm (-E|--putenv)
- conrolvm (keyboardputstring, keyboardputfile, audioin, audioout)
- storageattach (--passwordfile)
- modifymedium (--description)
2018-09-08 16:47:50 +02:00
2 changed files with 145 additions and 37 deletions

View File

@@ -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.1.36, and supports all commands (in some extent ;)).
5.2.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:

View File

@@ -4,7 +4,7 @@
# 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.36
# Version: 5.2.32
_VBoxManage() {
local cur prev opts cmd subcommand tmp items name index result
@@ -42,6 +42,18 @@ _VBoxManage() {
done
}
_is_any_item_used() {
local i
result=""
for i in $@; do
if [[ " ${COMP_WORDS[@]} " == *" $i "* ]]; then
result="ITIS"
break
fi
done
}
# Generate registered hard disk files.
# NOTE: This function may introduce some quirks, if there is a space or
# other characters which usually are treated as IFS - like space. Pipe
@@ -259,11 +271,14 @@ _VBoxManage() {
snap=$(VBoxManage snapshot "${name//\\/}" \
list | \
grep UUID |
awk -F ': ' '{print $2}' | \
sed 's/ (.*//' | \
tr '\n' '|' | \
sed 's/|$//' | \
sed 's/\s/\\ /g')
awk -F ': *' -v ORS='|' '/UUID: / {
n=$2; u=$3
sub(/..UUID/, "", n)
gsub(/ /, "\\ ", n);
sub(/[)].*/, "", u)
print n; print u
}'
)
IFS='|' read -ra snap <<< "$snap"
for item in "${snap[@]}"
@@ -443,7 +458,7 @@ _VBoxManage() {
# add debugvm command manually, since it's described differently in
# vboxmanage help
opts="${opts} debugvm"
opts="${opts} debugvm unattended"
if [[ ${cur} == "-q" || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
@@ -629,14 +644,15 @@ _VBoxManage() {
vrdevideochannelquality webcam videocap videocapscreens
videocapfile videocapres videocaprate videocapfps
videocapmaxtime videocapmaxsize addencpassword removeencpassword
removeallencpasswords)
removeallencpasswords keyboardputstring keyboardputfile audioin
audioout)
_find_item_name 2
subcommand=${COMP_WORDS[$((index+1))]}
if [[ " ${items[@]} " == *" $subcommand "* ]]; then
case "${subcommand}" in
nictracefile[1-8])
videocapfile|keyboardputfile|nictracefile[1-8])
[[ ${prev} == "nictracefile"* ]] && \
COMPREPLY=( $(compgen -f -- ${cur}) )
;;
@@ -659,7 +675,7 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "delete tcp
udp" -- ${cur}) )
;;
setlinkstate[1-8])
audioin|audioout|setlinkstate[1-8])
[[ ${prev} == "setlinkstate"* ]] && \
COMPREPLY=( $(compgen -W "on off" -- ${cur}) )
;;
@@ -670,8 +686,8 @@ _VBoxManage() {
;;
draganddrop)
[[ ${prev} == "draganddrop" ]] && \
COMPREPLY=( $(compgen -W "disabled
hosttoguest" -- ${cur}) )
COMPREPLY=( $(compgen -W "disabled hosttoguest
guesttohost bidirectional" -- ${cur}) )
;;
vrde|videocap)
[[ ${prev} == "vrde" ||
@@ -717,6 +733,8 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
esac
elif [[ ${prev} == "--passwordfile" || ${prev} == "--capturefile" ]]; then
COMPREPLY=( $(compgen -f -- ${cur}) )
else
[[ ${#COMPREPLY[@]} -eq 0 ]] && \
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
@@ -762,7 +780,7 @@ _VBoxManage() {
case "${prev}" in
--filename)
COMPREPLY=( $(compgen -- ${cur}) )
COMPREPLY=( $(compgen -f -- ${cur}) )
;;
--diffparent)
COMPREPLY=()
@@ -856,7 +874,7 @@ _VBoxManage() {
COMPREPLY+=( $(compgen -W "$result" -- ${cur}) )
else
[[ "${prev}" == "--filename" ]] && \
COMPREPLY=( $(compgen -- ${cur}) )
COMPREPLY=( $(compgen -f -- ${cur}) )
[[ ${#COMPREPLY[@]} -eq 0 ]] && \
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
fi
@@ -930,6 +948,8 @@ _VBoxManage() {
items=( --manifest --iso --options --vsys)
if [[ ${prev} == ${cmd} ]]; then
_vms_comp vms
elif [[ ${prev} == "--eulafile" ]]; then
COMPREPLY=( $(compgen -f -- ${cur}) )
else
[[ " ${COMP_WORDS[@]} " != *" -o "* &&
" ${COMP_WORDS[@]} " != *" --output "* ]] &&
@@ -937,8 +957,9 @@ _VBoxManage() {
[[ " ${COMP_WORDS[@]} " != *" --legacy09 "* &&
" ${COMP_WORDS[@]} " != *" --ovf09 "* &&
" ${COMP_WORDS[@]} " != *" --ovf10 "* &&
" ${COMP_WORDS[@]} " != *" --ovf20 "* ]] &&
items+=(--legacy09 --ovf09 --ovf10 --ovf20)
" ${COMP_WORDS[@]} " != *" --ovf20 "* &&
" ${COMP_WORDS[@]} " != *" --opc20 "* ]] &&
items+=(--legacy09 --ovf09 --ovf10 --ovf20 --opc10)
[[ " ${COMP_WORDS[@]} " == *" --vsys "* ]] &&
items+=(--product --producturl --vendor --vendorurl
--version --description --eula --eulafile)
@@ -1011,8 +1032,8 @@ _VBoxManage() {
--ignore-operhaned-processes --profile
--dos2unix --unix2dos --username --domain --)
[[ " ${comp_words[@]} " != *" --password "* ||
" ${comp_words[@]} " != *" --passwordfile "* ]] &&
[[ " ${COMP_WORDS[@]} " != *" --password "* ||
" ${COMP_WORDS[@]} " != *" --passwordfile "* ]] &&
items+=(--passwordfile --password)
[[ " ${COMP_WORDS[@]} " != *" --putenv "* &&
" ${COMP_WORDS[@]} " != *" -E "* ]] &&
@@ -1039,8 +1060,8 @@ _VBoxManage() {
--ignore-operhaned-processes --profile
--username --domain --passwordfile --password --)
[[ " ${comp_words[@]} " != *" --password "* ||
" ${comp_words[@]} " != *" --passwordfile "* ]] &&
[[ " ${COMP_WORDS[@]} " != *" --password "* ||
" ${COMP_WORDS[@]} " != *" --passwordfile "* ]] &&
items+=(--passwordfile --password)
[[ " ${COMP_WORDS[@]} " != *" --verbose "* &&
" ${COMP_WORDS[@]} " != *" -v "* ]] &&
@@ -1060,8 +1081,8 @@ _VBoxManage() {
[[ " ${COMP_WORDS[@]} " != *" --recursive "* &&
" ${COMP_WORDS[@]} " != *" -R "* ]] &&
items+=(--recursive -R)
[[ " ${comp_words[@]} " != *" --password "* ||
" ${comp_words[@]} " != *" --passwordfile "* ]] &&
[[ " ${COMP_WORDS[@]} " != *" --password "* ||
" ${COMP_WORDS[@]} " != *" --passwordfile "* ]] &&
items+=(--passwordfile --password)
[[ " ${COMP_WORDS[@]} " != *" --verbose "* &&
" ${COMP_WORDS[@]} " != *" -v "* ]] &&
@@ -1288,7 +1309,7 @@ _VBoxManage() {
--image)
COMPREPLY=( $(compgen -- ${cur}) )
;;
--tmpdir)
--target-directory|--tmpdir)
COMPREPLY=( $(compgen -o dirnames -- ${cur}) )
;;
--source)
@@ -1299,6 +1320,9 @@ _VBoxManage() {
"${COMPREPLY[0]}" != *".iso" ]] && \
COMPREPLY[0]="${COMPREPLY[0]}/"
;;
--passwordfile)
COMPREPLY=( $(compgen -f -- ${cur}) )
;;
esac
else
[[ ${#COMPREPLY[@]} -eq 0 ]] && \
@@ -1401,11 +1425,14 @@ _VBoxManage() {
_list_comp ${cur}
else
case "${prev}" in
--sorted|-s)
COMPREPLY=( $(compgen -W "-l --long" -- ${cur}) )
;;
--long|-l)
COMPREPLY=()
COMPREPLY=( $(compgen -W "-s --sorted" -- ${cur}) )
;;
*)
COMPREPLY=( $(compgen -W "-l --long" -- ${cur}) )
COMPREPLY=( $(compgen -W "-l --long -s --sorted" -- ${cur}) )
;;
esac
fi
@@ -1498,7 +1525,7 @@ _VBoxManage() {
*)
_find_item_name 2
items=(--type --autoreset --property --compact --resize
--move)
--move --description)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
case "${prev}" in
@@ -1523,7 +1550,7 @@ _VBoxManage() {
items=(--name --groups --description --ostype --iconfile --memory
--pagefusion --vram --acpi --pciattach --pcidetach --ioapic --hpet
--triplefaultreset --hwvirtex --nestedpaging --largepages --vtxvpid
--vtxux --pae --longmode --cpuidset --cpuidremove
--vtxux --pae --longmode --cpuid-set --cpuid-remove
--cpuidremoveall --hardwareuuid --cpus --cpuhotplug --plugcpu
--unplugcpu --cpuexecutioncap --rtcuseutc --graphicscontroller
--monitorcount --accelerate3d --accelerate2dvideo --firmware
@@ -1592,8 +1619,9 @@ _VBoxManage() {
--videocapmaxtime --videocapmaxsize --videocapopts --defaultfrontend
--cpuid-portability-level --paravirtprovider --audiocodec --usbxhci
--usbrename --apic --x2apic --paravirtdebug --cpu-profile
--biosapic --videocapopts --ibpb-on-vm-entry --ibpb-on-vm-exit
--spec-ctrl)
--biosapic --ibpb-on-vm-entry --ibpb-on-vm-exit --spec-ctrl
--audioin --audioout --l1d-flush-on-sched
--l1d-flush-on-vm-entry --mds-clear-on-sched --mds-clear-on-vm-entry)
if [[ ${prev} == ${cmd} ]]; then
_vms_comp vms
@@ -1633,7 +1661,9 @@ _VBoxManage() {
--usbehci|--teleporter|--tracing-enabled|\
--tracing-allow-vm-access|--usbcardreader|\
--autostart-enabled|--videocap|--usbxhci|--apic|--x2apic|\
--ibpb-on-vm-entry|--ibpb-on-vm-exit|--spec-ctrl)
--ibpb-on-vm-entry|--ibpb-on-vm-exit|--spec-ctrl|--audioin|\
--audioout|--l1d-flush-on-sched|--l1d-flush-on-vm-entry|\
--mds-clear-on-sched|--mds-clear-on-vm-entry)
COMPREPLY=( $(compgen -W "on off" -- ${cur}) )
;;
@@ -1762,8 +1792,8 @@ _VBoxManage() {
;;
--draganddrop)
COMPREPLY+=( $(compgen -W "disabled hosttoguest" \
-- ${cur}) )
COMPREPLY+=( $(compgen -W "disabled hosttoguest
guesttohost bidirectional" -- ${cur}) )
;;
--vrdeextpack|--vrdeauthlibrary|--snapshotfolder|\
@@ -1794,6 +1824,15 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "disabled apic x2apic" \
-- ${cur}) )
;;
--teleporterpasswordfile|--iconfile|--videocapfile)
COMPREPLY=( $(compgen -f -- ${cur}) )
;;
--nictracefile[1-8])
COMPREPLY=( $(compgen -f -- ${cur}) )
;;
--nattftpfile[1-8])
COMPREPLY=( $(compgen -f -- ${cur}) )
;;
esac
fi
;;
@@ -2013,7 +2052,13 @@ _VBoxManage() {
elif [[ "${prev}" == "--type" ]]; then
COMPREPLY=( $(compgen -W "gui sdl headless separate" -- ${cur}) )
else
local items=(--putenv -E)
_is_any_item_used "${items[@]}"
if [[ "${result}" == "ITIS" ]]; then
local items=(--type)
else
local items=(--type -E --putenv)
fi
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
fi
@@ -2028,7 +2073,7 @@ _VBoxManage() {
--comment --setuuid --setparentuuid --passthrough --tempeject
--nonrotational --discard --hotpluggable --bandwidthgroup
--forceunmount --server --target --tport --lun --encodedlun
--username --password --initiator --intnet)
--username --password --initiator --intnet --passwordfile)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
@@ -2054,6 +2099,9 @@ _VBoxManage() {
--passthrough|--tempeject|--nonrotational|--discard)
COMPREPLY=( $(compgen -W "on off" -- ${cur}) )
;;
--passwordfile)
COMPREPLY=( $(compgen -f -- ${cur}) )
;;
esac
fi
;;
@@ -2156,6 +2204,66 @@ _VBoxManage() {
fi
fi
;;
unattended)
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 "detect install" -- ${cur}) )
else
case "${prev}" in
--iso|--password-file|--additions-iso|--validation-kit-iso|\
--script-template|--post-install-template)
COMPREPLY+=( $(compgen -f -- ${cur}) )
;;
--auxiliary-base-path)
COMPREPLY+=( $(compgen -o dirnames -- ${cur}) )
;;
--start-vm)
COMPREPLY=( $(compgen -W "gui sdl headless separate" \
-- ${cur}) )
;;
esac
if [[ ${#COMPREPLY[@]} -eq 0 ]]; then
case "${subcommand}" in
detect)
local items=(--iso --machine-readable)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
install)
if [[ ${prev} == ${subcommand} ]]; then
_vms_comp vms
else
local items=(--iso --user=login
--password=password --password-file
--full-user-name --key
--install-additions --no-install-additions
--additions-iso --install-txs --no-install-txs
--validation-kit-iso --locale --country
--time-zone --hostname
--package-selection-adjustment --dry-run
--auxiliary-base-path=path --image-index
--script-template --post-install-template
--post-install-command
--extra-install-kernel-parameters --language
--start-vm)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
fi
;;
esac
fi
fi
;;
esac
}
complete -o default -F _VBoxManage VBoxManage