10 Commits

Author SHA1 Message Date
7174fe03db Bump to version 6.1.22.
There were cloud network command added.
2021-08-01 17:40:51 +02:00
f2d71065cb Removed trailing spaces. 2021-08-01 17:39:56 +02:00
82e2fade6b Change approach with getting commands out of help.
There are currently two ways for specify available commands in
vboxmanage help:

Usage:

  VBoxManage [<general option>] <command>
[..]
Commands:

  command1 ...

  command2 ...

and:

  VBoxManage command3 ...

  VBoxManage command4 ...

besides the fact how it is annoying for parsing the output (or lack of
having some way for machine readable format for commands), I have
treated the latter as a exception from general rule, but lately it
slowly moving towards the second form. In this patch it is adapted to
also parse second format instead of adding those commands manually.

Also, there was missing parameter added for sharedfolder add command.
2021-07-27 20:10:58 +02:00
8360d95123 Bump to 6.1.10 2020-07-21 14:30:48 +02:00
12b0f38741 Bump to version 6.1.6 2020-05-18 20:06:25 +02:00
808c4ac277 Merge pull request #10 from schplurtz/sedasfunc
define sed as a function
2020-02-17 08:00:53 +01:00
Schplurtz le Déboulonné
31a7eec15a use sed from global var VBMC_SED instead of function 2020-02-16 18:45:56 +01:00
Schplurtz le Déboulonné
0ffc79dbe2 fix syntax error in _vbmc_sed 2020-02-15 23:13:26 +01:00
Schplurtz le Déboulonné
1ed71c9253 define sed as a function 2020-02-15 14:55:06 +01:00
35bce20ef5 Bump to 6.1.0 2019-12-25 12:24:22 +01:00
2 changed files with 405 additions and 80 deletions

View File

@@ -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
6.0.12, and should contain all commands and their options. 6.1.22, 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:

View File

@@ -4,11 +4,15 @@
# URL: https://bitbucket.org/gryf/vboxmanage-bash-completion # URL: https://bitbucket.org/gryf/vboxmanage-bash-completion
# 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: 6.0.12 # Version: 6.1.10
_VBoxManage() { _VBoxManage() {
local cur prev opts cmd subcommand tmp items name index result local cur prev opts cmd subcommand tmp items name index result
# env var GNUSED is either empty or points to a gnu sed executable
VBMC_SED=${GNUSED:-sed}
# Check the COMP_WORDS looking for name of the vm. If name contain space or # Check the COMP_WORDS looking for name of the vm. If name contain space or
# is enclosed in quotes, glue name together in variable name. Variable index # is enclosed in quotes, glue name together in variable name. Variable index
# will hold the last index of COMP_WORDS array which contain the end of the # will hold the last index of COMP_WORDS array which contain the end of the
@@ -65,10 +69,10 @@ _VBoxManage() {
hdds=$(VBoxManage list hdds | \ hdds=$(VBoxManage list hdds | \
grep -A 1 'normal (base)' | \ grep -A 1 'normal (base)' | \
grep "Location:" | \ grep "Location:" | \
sed 's/Location:\s\+//' | \ $VBMC_SED 's/Location:\s\+//' | \
sed 's/\s/\\ /g' | \ $VBMC_SED 's/\s/\\ /g' | \
tr '\n' '|' | \ tr '\n' '|' | \
sed 's/|$//') $VBMC_SED 's/|$//')
IFS='|' read -ra hdds <<< "$hdds" IFS='|' read -ra hdds <<< "$hdds"
for item in "${hdds[@]}" for item in "${hdds[@]}"
@@ -83,10 +87,10 @@ _VBoxManage() {
floppies=$(VBoxManage list floppies | \ floppies=$(VBoxManage list floppies | \
grep "Location:" | \ grep "Location:" | \
sed 's/Location:\s\+//' | \ $VBMC_SED 's/Location:\s\+//' | \
sed 's/\s/\\ /g' | \ $VBMC_SED 's/\s/\\ /g' | \
tr '\n' '|' | \ tr '\n' '|' | \
sed 's/|$//') $VBMC_SED 's/|$//')
IFS='|' read -ra floppies <<< "$floppies" IFS='|' read -ra floppies <<< "$floppies"
for item in "${floppies[@]}" for item in "${floppies[@]}"
@@ -101,10 +105,10 @@ _VBoxManage() {
dvds=$(VBoxManage list dvds | \ dvds=$(VBoxManage list dvds | \
grep "Location:" | \ grep "Location:" | \
sed 's/Location:\s\+//' | \ $VBMC_SED 's/Location:\s\+//' | \
sed 's/\s/\\ /g' | \ $VBMC_SED 's/\s/\\ /g' | \
tr '\n' '|' | \ tr '\n' '|' | \
sed 's/|$//') $VBMC_SED 's/|$//')
IFS='|' read -ra dvds <<< "$dvds" IFS='|' read -ra dvds <<< "$dvds"
for item in "${dvds[@]}" for item in "${dvds[@]}"
@@ -130,16 +134,16 @@ _VBoxManage() {
running_vms=$(VBoxManage list runningvms | \ running_vms=$(VBoxManage list runningvms | \
awk -F ' {' '{ print $1 }' | \ awk -F ' {' '{ print $1 }' | \
tr '\n' '|' | \ tr '\n' '|' | \
sed 's/|$//' | \ $VBMC_SED 's/|$//' | \
sed 's/"//g') $VBMC_SED 's/"//g')
IFS='|' read -ra running_vms <<< "$running_vms" IFS='|' read -ra running_vms <<< "$running_vms"
fi fi
vms=$(VBoxManage list $command | \ vms=$(VBoxManage list $command | \
awk -F ' {' '{ print $1 }' | \ awk -F ' {' '{ print $1 }' | \
tr '\n' '|' | \ tr '\n' '|' | \
sed 's/|$//' | \ $VBMC_SED 's/|$//' | \
sed 's/"//g') $VBMC_SED 's/"//g')
IFS='|' read -ra vms <<< "$vms" IFS='|' read -ra vms <<< "$vms"
for item in "${vms[@]}" for item in "${vms[@]}"
do do
@@ -162,10 +166,10 @@ _VBoxManage() {
vms=$(VBoxManage list vms -l | \ vms=$(VBoxManage list vms -l | \
egrep '^Name|State' | \ egrep '^Name|State' | \
egrep -B1 'State:\s+saved' | \ egrep -B1 'State:\s+saved' | \
grep Name |sed 's/Name:\s\+//' | \ grep Name |$VBMC_SED 's/Name:\s\+//' | \
tr '\n' '|' | \ tr '\n' '|' | \
sed 's/|$//' | \ $VBMC_SED 's/|$//' | \
sed 's/"//g') $VBMC_SED 's/"//g')
IFS='|' read -ra vms <<< "$vms" IFS='|' read -ra vms <<< "$vms"
for item in "${vms[@]}" for item in "${vms[@]}"
do do
@@ -179,9 +183,9 @@ _VBoxManage() {
list=$(VBoxManage list groups | \ list=$(VBoxManage list groups | \
tr '\n' '|' | \ tr '\n' '|' | \
sed 's/|$//' | \ $VBMC_SED 's/|$//' | \
sed 's/\s/\\ /g'| \ $VBMC_SED 's/\s/\\ /g'| \
sed 's/"//g') $VBMC_SED 's/"//g')
IFS='|' read -ra list <<< "$list" IFS='|' read -ra list <<< "$list"
for item in "${list[@]}" for item in "${list[@]}"
@@ -196,9 +200,9 @@ _VBoxManage() {
list=$(VBoxManage list ostypes | \ list=$(VBoxManage list ostypes | \
egrep ^ID: | \ egrep ^ID: | \
sed 's/ID:\s\+//' | \ $VBMC_SED 's/ID:\s\+//' | \
tr '\n' '|' | \ tr '\n' '|' | \
sed 's/|$//') $VBMC_SED 's/|$//')
IFS='|' read -ra list <<< "$list" IFS='|' read -ra list <<< "$list"
for item in "${list[@]}" for item in "${list[@]}"
@@ -213,10 +217,10 @@ _VBoxManage() {
list=$(VBoxManage list dhcpservers | \ list=$(VBoxManage list dhcpservers | \
grep NetworkName: | \ grep NetworkName: | \
sed 's/NetworkName:\s\+//' | \ $VBMC_SED 's/NetworkName:\s\+//' | \
sed 's/\s/\\ /g'| \ $VBMC_SED 's/\s/\\ /g'| \
tr '\n' '|' | \ tr '\n' '|' | \
sed 's/|$//') $VBMC_SED 's/|$//')
IFS='|' read -ra list <<< "$list" IFS='|' read -ra list <<< "$list"
for item in "${list[@]}" for item in "${list[@]}"
@@ -231,10 +235,10 @@ _VBoxManage() {
list=$(VBoxManage list hostonlyifs | \ list=$(VBoxManage list hostonlyifs | \
egrep ^Name: | \ egrep ^Name: | \
sed 's/Name:\s\+//' | \ $VBMC_SED 's/Name:\s\+//' | \
sed 's/\s/\\ /g'| \ $VBMC_SED 's/\s/\\ /g'| \
tr '\n' '|' | \ tr '\n' '|' | \
sed 's/|$//') $VBMC_SED 's/|$//')
IFS='|' read -ra list <<< "$list" IFS='|' read -ra list <<< "$list"
for item in "${list[@]}" for item in "${list[@]}"
@@ -253,8 +257,8 @@ _VBoxManage() {
awk -F ',' '{print $1}' | \ awk -F ',' '{print $1}' | \
awk -F '=' '{print $2}' | \ awk -F '=' '{print $2}' | \
tr '\n' '|' | \ tr '\n' '|' | \
sed 's/|$//' | \ $VBMC_SED 's/|$//' | \
sed 's/\s/\\ /g') $VBMC_SED 's/\s/\\ /g')
IFS='|' read -ra rules <<< "$rules" IFS='|' read -ra rules <<< "$rules"
for item in "${rules[@]}" for item in "${rules[@]}"
@@ -295,7 +299,7 @@ _VBoxManage() {
devs=$(VBoxManage controlvm "${name//\\/}" \ devs=$(VBoxManage controlvm "${name//\\/}" \
webcam list | \ webcam list | \
tr '\n' ' ' | \ tr '\n' ' ' | \
sed 's/|s$//') $VBMC_SED 's/|s$//')
read -ra devs <<< "$devs" read -ra devs <<< "$devs"
for item in "${devs[@]}" for item in "${devs[@]}"
@@ -312,7 +316,7 @@ _VBoxManage() {
devs=$(VBoxManage list webcams | \ devs=$(VBoxManage list webcams | \
grep dev | \ grep dev | \
tr '\n' ' ' | \ tr '\n' ' ' | \
sed 's/|s$//') $VBMC_SED 's/|s$//')
read -ra devs <<< "$devs" read -ra devs <<< "$devs"
for item in "${devs[@]}" for item in "${devs[@]}"
@@ -323,7 +327,7 @@ _VBoxManage() {
_list_comp() { _list_comp() {
local list local list
list=$(VBoxManage list | sed -e '1,2d' \ list=$(VBoxManage list | $VBMC_SED -e '1,2d' \
-e 's/VBoxManage list //' \ -e 's/VBoxManage list //' \
-e 's/[\[\]\|]/ /g' \ -e 's/[\[\]\|]/ /g' \
-e 's/|/ /g'|xargs echo) -e 's/|/ /g'|xargs echo)
@@ -338,10 +342,10 @@ _VBoxManage() {
folders=$(VBoxManage showvminfo ${vm} --machinereadable | \ folders=$(VBoxManage showvminfo ${vm} --machinereadable | \
grep SharedFolderName | \ grep SharedFolderName | \
awk -F= '{print $2}' | \ awk -F= '{print $2}' | \
sed 's/\s/\\ /g'| \ $VBMC_SED 's/\s/\\ /g'| \
tr '\n' '|' | \ tr '\n' '|' | \
sed 's/|$//' | \ $VBMC_SED 's/|$//' | \
sed 's/"//g') $VBMC_SED 's/"//g')
IFS='|' read -ra folders <<< "$folders" IFS='|' read -ra folders <<< "$folders"
for item in "${folders[@]}" for item in "${folders[@]}"
@@ -356,10 +360,10 @@ _VBoxManage() {
list=$(VBoxManage list natnets | \ list=$(VBoxManage list natnets | \
grep NetworkName: | \ grep NetworkName: | \
sed 's/NetworkName:\s\+//' | \ $VBMC_SED 's/NetworkName:\s\+//' | \
sed 's/\s/\\ /g'| \ $VBMC_SED 's/\s/\\ /g'| \
tr '\n' '|' | \ tr '\n' '|' | \
sed 's/|$//') $VBMC_SED 's/|$//')
IFS='|' read -ra list <<< "$list" IFS='|' read -ra list <<< "$list"
for item in "${list[@]}" for item in "${list[@]}"
@@ -374,10 +378,10 @@ _VBoxManage() {
list=$(VBoxManage list bridgedifs | \ list=$(VBoxManage list bridgedifs | \
egrep ^Name: | \ egrep ^Name: | \
sed 's/Name:\s\+//' | \ $VBMC_SED 's/Name:\s\+//' | \
sed 's/\s/\\ /g'| \ $VBMC_SED 's/\s/\\ /g'| \
tr '\n' '|' | \ tr '\n' '|' | \
sed 's/|$//') $VBMC_SED 's/|$//')
IFS='|' read -ra list <<< "$list" IFS='|' read -ra list <<< "$list"
for item in "${list[@]}" for item in "${list[@]}"
@@ -392,10 +396,10 @@ _VBoxManage() {
list=$(VBoxManage list intnets| \ list=$(VBoxManage list intnets| \
egrep ^Name: | \ egrep ^Name: | \
sed 's/Name:\s\+//' | \ $VBMC_SED 's/Name:\s\+//' | \
sed 's/\s/\\ /g'| \ $VBMC_SED 's/\s/\\ /g'| \
tr '\n' '|' | \ tr '\n' '|' | \
sed 's/|$//') $VBMC_SED 's/|$//')
IFS='|' read -ra list <<< "$list" IFS='|' read -ra list <<< "$list"
for item in "${list[@]}" for item in "${list[@]}"
@@ -432,6 +436,42 @@ _VBoxManage() {
esac esac
} }
_cloudproviders_comp() {
local providers
local item
providers=$(VBoxManage list cloudproviders | \
grep "Short Name:" | \
$VBMC_SED 's/Short Name:\s\+//' | \
$VBMC_SED 's/\s/\\ /g' | \
tr '\n' '|' | \
$VBMC_SED 's/|$//')
IFS='|' read -ra providers <<< "$providers"
for item in "${providers[@]}"
do
[[ ${item^^} == ${cur^^}* ]] && COMPREPLY+=("$item")
done
}
_cloudprofiles_comp() {
local profiles
local item
profiles=$(VBoxManage list cloudprofiles | \
grep "Name:" | \
$VBMC_SED 's/Name:\s\+//' | \
$VBMC_SED 's/\s/\\ /g' | \
tr '\n' '|' | \
$VBMC_SED 's/|$//')
IFS='|' read -ra profiles <<< "$profiles"
for item in "${profiles[@]}"
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=()
@@ -446,15 +486,18 @@ _VBoxManage() {
# all possible commands for the VBoxManage # all possible commands for the VBoxManage
opts=$(VBoxManage -q help | \ opts=$(VBoxManage -q help | \
egrep -o "^\s\s[a-z]+ " | \ grep -E -o "^\s\s[a-z]+ " | \
grep -v VBoxManage | \ grep -v VBoxManage | \
awk '{print $1}'| \ awk '{print $1}'| \
sort | \ sort | \
uniq) uniq)
# Add some commands manually, since they are listed differently in # Add commands which are defined as ` VBoxManage commandname ` in a help.
# vboxmanage help. opts="${opts} $(VBoxManage -q help | \
opts="${opts} mediumio debugvm unattended extpack" grep -E -o '^\s\s[a-zA-Z]+\s[a-z]+' | \
awk '{print $2}'| \
sort | \
uniq)"
if [[ ${cur} == "-q" || ${COMP_CWORD} -eq 1 ]] ; then if [[ ${cur} == "-q" || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
@@ -565,7 +608,7 @@ _VBoxManage() {
else else
_find_item_name 2 _find_item_name 2
items=(--snapshot --mode --options --name --groups --basefolder items=(--snapshot --mode --options --name --groups --basefolder
--uuid --register) --uuid --register --snapshot)
_get_excluded_items "${items[@]}" _get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) ) COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
case "${prev}" in case "${prev}" in
@@ -618,6 +661,163 @@ _VBoxManage() {
fi fi
;; ;;
cloudprofile)
if [[ " ${COMP_WORDS[@]} " != *" --provider"* ||
" ${COMP_WORDS[@]} " != *" --profile"* ]]; then
items=(--provider --profile)
else
[[ " ${COMP_WORDS[@]} " != *" add"* &&
" ${COMP_WORDS[@]} " != *" update"* &&
" ${COMP_WORDS[@]} " != *" delete"* &&
" ${COMP_WORDS[@]} " != *" show"* ]] &&
items=(add update delete show)
fi
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
case "${prev}" in
--provider)
COMPREPLY=()
_cloudproviders_comp
;;
--profile)
COMPREPLY=()
_cloudprofiles_comp
;;
esac
if [[ " ${COMP_WORDS[@]} " == *" add"* ||
" ${COMP_WORDS[@]} " == *" update"* ]]; then
COMPREPLY=( $(compgen -W "--clouduser --fingerprint --keyfile
--passphrase --tenancy --compartment" -- ${cur}) )
fi
;;
cloud)
if [ "${prev}" == "cloud" ]; then
items=(--provider --profile network)
elif [[ " ${COMP_WORDS[@]} " == *" network"* ]]; then
items=(update delete info)
elif [[ " ${COMP_WORDS[@]} " != *" --provider"* ||
" ${COMP_WORDS[@]} " != *" --profile"* ]]; then
items=(--provider --profile)
else
[[ " ${COMP_WORDS[@]} " != *" list"* &&
" ${COMP_WORDS[@]} " != *" instance"* &&
" ${COMP_WORDS[@]} " != *" network"* &&
" ${COMP_WORDS[@]} " != *" image"* ]] &&
items=(list instance image network)
fi
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
case "${prev}" in
--provider)
COMPREPLY=()
_cloudproviders_comp
;;
--profile)
COMPREPLY=()
_cloudprofiles_comp
;;
list)
COMPREPLY=( $(compgen -W "instances images" -- ${cur}) )
;;
instance)
COMPREPLY=( $(compgen -W "create info terminate start
pause" -- ${cur}) )
;;
image)
COMPREPLY=( $(compgen -W "create info delete import
export" -- ${cur}) )
;;
network) # TODO: differentiate between setup/create and update/delete/info
if [[ " ${COMP_WORDS[@]} " == *" --provider"* ]]; then
COMPREPLY=( $(compgen -W "setup create" -- ${cur}) )
fi
;;
esac
if [[ " ${COMP_WORDS[@]} " == *" list images"* ]]; then
items=(--state --compartment-id)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
fi
if [[ " ${COMP_WORDS[@]} " == *" instance create"* ]]; then
items=( --domain-name --display-name --shape --subnet
--publicip --boot-disk-size --privateip --public-ssh-key
--launch-mode --cloud-init-script-path )
[[ " ${COMP_WORDS[@]} " != *" --image-id"* &&
" ${COMP_WORDS[@]} " != *" --boot-volume-id"* ]] &&
items+=(--image-id --boot-volume-id)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
case "${prev}" in
--publicip)
COMPREPLY=( $(compgen -W "true false" -- ${cur}) )
;;
--launch-mode)
COMPREPLY=( $(compgen -W "NATIVE EMULATED
PARAVIRTUALIZED" -- ${cur}) )
;;
esac
fi
if [[ " ${COMP_WORDS[@]} " == *" instance info"* ||
" ${COMP_WORDS[@]} " == *" instance terminate"* ||
" ${COMP_WORDS[@]} " == *" instance start"* ||
" ${COMP_WORDS[@]} " == *" instance pause"* ]]; then
COMPREPLY=( $(compgen -W "--id" -- ${cur}) )
fi
if [[ " ${COMP_WORDS[@]} " == *" image create"* ]]; then
items=(--display-name --bucket-name --object-name --instance-id)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
fi
if [[ " ${COMP_WORDS[@]} " == *" image info"* ||
" ${COMP_WORDS[@]} " == *" image delete"* ]]; then
COMPREPLY=( $(compgen -W "--id" -- ${cur}) )
fi
if [[ " ${COMP_WORDS[@]} " == *" image import"* ]]; then
COMPREPLY=( $(compgen -W "--id --bucket-name
--object-name" -- ${cur}) )
fi
if [[ " ${COMP_WORDS[@]} " == *" image export"* ]]; then
COMPREPLY=( $(compgen -W "--id --display-name --bucket-name
--object-name" -- ${cur}) )
fi
if [[ " ${COMP_WORDS[@]} " == *" network setup"* ]]; then
items=( --local-gateway-iso --gateway-os-name
--gateway-os-version --gateway-shape --tunnel-network-name
--tunnel-network-range --guest-additions-iso --proxy
--compartment-id )
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
fi
if [[ " ${COMP_WORDS[@]} " == *" network create"* ]]; then
items=( --name --network-id )
[[ " ${COMP_WORDS[@]} " != *" --enable"* &&
" ${COMP_WORDS[@]} " != *" --disable"* ]] &&
items+=(--enable --disable)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
fi
if [[ " ${COMP_WORDS[@]} " == *" network update"* ]]; then
items=( --name --network-id )
[[ " ${COMP_WORDS[@]} " != *" --enable"* &&
" ${COMP_WORDS[@]} " != *" --disable"* ]] &&
items+=(--enable --disable)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
fi
if [[ " ${COMP_WORDS[@]} " == *" network info"* ||
" ${COMP_WORDS[@]} " == *" network delete"* ]]; then
COMPREPLY=( $(compgen -W "--name" -- ${cur}) )
fi
;;
controlvm) controlvm)
if [[ ${prev} == ${cmd} ]]; then if [[ ${prev} == ${cmd} ]]; then
_vms_comp runningvms _vms_comp runningvms
@@ -640,7 +840,7 @@ _VBoxManage() {
vrdevideochannelquality webcam recording addencpassword vrdevideochannelquality webcam recording addencpassword
removeencpassword removeallencpasswords keyboardputstring removeencpassword removeallencpasswords keyboardputstring
keyboardputfile audioin audioout setscreenlayout changeuartmode1 keyboardputfile audioin audioout setscreenlayout changeuartmode1
changeuartmode2) changeuartmode2 vm-process-priority)
_find_item_name 2 _find_item_name 2
subcommand=${COMP_WORDS[$((index+1))]} subcommand=${COMP_WORDS[$((index+1))]}
@@ -747,6 +947,11 @@ _VBoxManage() {
_get_excluded_items "${tmp[@]}" _get_excluded_items "${tmp[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) ) COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;; ;;
vm-process-priority)
COMPREPLY=( $(compgen -W "default flat low normal
high" -- ${cur}) )
;;
esac esac
elif [[ ${prev} == "--passwordfile" || ${prev} == "--capturefile" ]]; then elif [[ ${prev} == "--passwordfile" || ${prev} == "--capturefile" ]]; then
COMPREPLY=( $(compgen -f -- ${cur}) ) COMPREPLY=( $(compgen -f -- ${cur}) )
@@ -898,16 +1103,15 @@ _VBoxManage() {
;; ;;
dhcpserver) dhcpserver)
items=(add modify remove) items=(add modify remove restart findlease)
subcommand=${COMP_WORDS[2]} subcommand=${COMP_WORDS[2]}
if [[ " ${items[@]} " == *" $subcommand "* ]]; then if [[ " ${items[@]} " == *" $subcommand "* ]]; then
case "${subcommand}" in case "${subcommand}" in
add|modify) add)
items=(--ip --netmask --lowerip --upperip --options) items=(--server-ip --netmask --lower-ip --upper-ip)
[[ " ${COMP_WORDS[@]} " != *" --interface"* &&
[[ " ${COMP_WORDS[@]} " != *" --ifname"* && " ${COMP_WORDS[@]} " != *" --network"* ]] &&
" ${COMP_WORDS[@]} " != *" --netname"* ]] && items+=(--network --interface)
items+=(--netname --ifname)
[[ " ${COMP_WORDS[@]} " != *" --enable"* && [[ " ${COMP_WORDS[@]} " != *" --enable"* &&
" ${COMP_WORDS[@]} " != *" --disable"* ]] && " ${COMP_WORDS[@]} " != *" --disable"* ]] &&
@@ -916,24 +1120,126 @@ _VBoxManage() {
[[ " ${COMP_WORDS[@]} " == *" --options"* ]] && [[ " ${COMP_WORDS[@]} " == *" --options"* ]] &&
items+=(--vm --nic --id --value --remove) items+=(--vm --nic --id --value --remove)
[[ " ${COMP_WORDS[@]} " != *" --global"* &&
" ${COMP_WORDS[@]} " != *" --group"* &&
" ${COMP_WORDS[@]} " != *" --vm"* &&
" ${COMP_WORDS[@]} " != *" --mac-address"* ]] &&
items+=(--global --group --vm --mac-address)
[[ " ${COMP_WORDS[@]} " == *" --global"* ]] &&
items+=(--set-opt --set-opt-hex --force-opt
--supress-opt --min-lease-time --default-lease-time
--max-lease-time)
[[ " ${COMP_WORDS[@]} " == *" --group"* ]] &&
items+=(--set-opt --set-opt-hex --force-opt
--supress-opt --incl-mac --excl-mac --incl-mac-wild
--excl-mac-wild --incl-vendor --excl-vendor
--incl-vendor-wild --excl-vendor-wild --incl-user
--excl-user --incl-user-wild --excl-user-wild
--min-lease-time --default-lease-time
--max-lease-time)
[[ " ${COMP_WORDS[@]} " == *" --vm"* ]] &&
items+=(--nic --set-opt --set-opt-hex --force-opt
--supress-opt --min-lease-time --default-lease-time
--max-lease-time --fixed-address)
[[ " ${COMP_WORDS[@]} " == *" --mac-address"* ]] &&
items+=(--set-opt --set-opt-hex --force-opt
--supress-opt --min-lease-time --default-lease-time
--max-lease-time --fixed-address)
_get_excluded_items "${items[@]}" _get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) ) COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;; ;;
remove) modify)
items=(--server-ip --netmask --lower-ip --upper-ip)
[[ " ${COMP_WORDS[@]} " != *" --interface"* &&
" ${COMP_WORDS[@]} " != *" --network"* ]] &&
items+=(--network --interface)
[[ " ${COMP_WORDS[@]} " != *" --enable"* &&
" ${COMP_WORDS[@]} " != *" --disable"* ]] &&
items+=(--enable --disable)
[[ " ${COMP_WORDS[@]} " == *" --options"* ]] &&
items+=(--vm --nic --id --value --remove)
[[ " ${COMP_WORDS[@]} " != *" --global"* &&
" ${COMP_WORDS[@]} " != *" --group"* &&
" ${COMP_WORDS[@]} " != *" --vm"* &&
" ${COMP_WORDS[@]} " != *" --mac-address"* ]] &&
items+=(--global --group --vm --mac-address)
[[ " ${COMP_WORDS[@]} " == *" --global"* ]] &&
items+=(--del-opt --set-opt --set-opt-hex --force-opt
--unforce-opt --supress-opt --unsupress-opt
--min-lease-time --default-lease-time
--max-lease-time --remove-config)
[[ " ${COMP_WORDS[@]} " == *" --group"* ]] &&
items+=(--set-opt-hex --force-opt --unforce-opt
--supress-opt --unsupress-opt --del-mac --incl-mac
--excl-mac --del-mac-wild --incl-mac-wild
--excl-mac-wild --del-vendor --incl-vendor
--excl-vendor --del-vendor-wild --incl-vendor-wild
--excl-vendor-wild --del-user --incl-user
--excl-user --del-user-wild --incl-user-wild
--excl-user-wild --zap-conditions --min-lease-time
--default-lease-time --max-lease-time
--remove-config)
[[ " ${COMP_WORDS[@]} " == *" --vm"* ]] &&
items+=(--del-opt --set-opt --set-opt-hex --force-opt
--unforce-opt --supress-opt --unsupress-opt
--min-lease-time --default-lease-time
--max-lease-time --fixed-address --remove-config)
[[ " ${COMP_WORDS[@]} " == *" --mac-address"* ]] &&
items+=(--set-opt --set-opt-hex --force-opt
--unforce-opt --supress-opt --unsupress-opt
--min-lease-time --default-lease-time
--max-lease-time --fixed-address --remove-config)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
remove|restart)
case "${prev}" in case "${prev}" in
--netname) --network)
COMPREPLY=() COMPREPLY=()
_dhcp_comp _dhcp_comp
;; ;;
--ifname) --interface)
COMPREPLY=() COMPREPLY=()
_hostonlyif_comp _hostonlyif_comp
;; ;;
esac esac
if [[ " ${COMP_WORDS[@]} " != *" --ifname"* && if [[ " ${COMP_WORDS[@]} " != *" --interface"* &&
" ${COMP_WORDS[@]} " != *" --netname"* ]]; then " ${COMP_WORDS[@]} " != *" --network"* ]]; then
items=(--netname --ifname) items=(--network --interface)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
fi
;;
findlease)
items=(--mac-address)
case "${prev}" in
--network)
COMPREPLY=()
_dhcp_comp
;;
--interface)
COMPREPLY=()
_hostonlyif_comp
;;
esac
if [[ " ${COMP_WORDS[@]} " != *" --interface"* &&
" ${COMP_WORDS[@]} " != *" --network"* ]]; then
items+=(--network --interface)
_get_excluded_items "${items[@]}" _get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) ) COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
fi fi
@@ -964,7 +1270,8 @@ _VBoxManage() {
;; ;;
"export") "export")
items=( --manifest --iso --options --vsys --cloud) items=( --manifest --iso --options --vsys --cloud
--cloudinitscriptpath )
if [[ ${prev} == ${cmd} ]]; then if [[ ${prev} == ${cmd} ]]; then
_vms_comp vms _vms_comp vms
elif [[ ${prev} == "--eulafile" ]]; then elif [[ ${prev} == "--eulafile" ]]; then
@@ -989,7 +1296,8 @@ _VBoxManage() {
[[ " ${COMP_WORDS[@]} " == *" --cloud"* ]] && [[ " ${COMP_WORDS[@]} " == *" --cloud"* ]] &&
items+=(--vmname --cloudprofile --cloudshape --clouddomain items+=(--vmname --cloudprofile --cloudshape --clouddomain
--clouddisksize --cloudbucket --cloudocivcn --cloudocisubnet --clouddisksize --cloudbucket --cloudocivcn --cloudocisubnet
--cloudkeepobject --cloudlaunchinstance --cloudpublicip) --cloudkeepobject --cloudlaunchinstance --cloudpublicip
--cloudprivateip --cloudlaunchmode --cloudinitscriptpath )
_get_excluded_items "${items[@]}" _get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) ) COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
@@ -998,7 +1306,10 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "manifest iso nomacs COMPREPLY=( $(compgen -W "manifest iso nomacs
nomacsbutnat" -- ${cur}) ) nomacsbutnat" -- ${cur}) )
;; ;;
--cloudlaunchmode)
COMPREPLY=( $(compgen -W "EMULATED PARAVIRTUALIZED" \
-- ${cur}) )
;;
esac esac
[[ ${#COMPREPLY[@]} -eq 0 ]] && \ [[ ${#COMPREPLY[@]} -eq 0 ]] && \
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
@@ -1011,7 +1322,7 @@ _VBoxManage() {
if [[ " ${items[@]} " == *" $subcommand "* ]]; then if [[ " ${items[@]} " == *" $subcommand "* ]]; then
case "${subcommand}" in case "${subcommand}" in
install) install)
_get_excluded_items "--replace" _get_excluded_items "--replace --accept-license"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) ) COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;; ;;
uninstall) uninstall)
@@ -1426,7 +1737,8 @@ _VBoxManage() {
;; ;;
import) import)
items=(--options) items=(--options --dry-run -n --vmname --cloud --cloudprofile
--cloudinstanceid --cloudbucket)
if [[ "${prev}" == "import" ]]; then if [[ "${prev}" == "import" ]]; then
COMPREPLY=( $(compgen -o plusdirs -f -X '!@(*.ovf|*.ova)' \ COMPREPLY=( $(compgen -o plusdirs -f -X '!@(*.ovf|*.ova)' \
-- ${cur}) ) -- ${cur}) )
@@ -1604,7 +1916,7 @@ _VBoxManage() {
modifyvm) modifyvm)
items=(--name --groups --description --ostype --iconfile --memory items=(--name --groups --description --ostype --iconfile --memory
--pagefusion --vram --acpi --pciattach --pcidetach --ioapic --hpet --pagefusion --vram --acpi --ioapic --hpet
--triplefaultreset --hwvirtex --nestedpaging --largepages --vtxvpid --triplefaultreset --hwvirtex --nestedpaging --largepages --vtxvpid
--vtxux --pae --longmode --cpuid-set --cpuid-remove --vtxux --pae --longmode --cpuid-set --cpuid-remove
--cpuidremoveall --hardwareuuid --cpus --cpuhotplug --plugcpu --cpuidremoveall --hardwareuuid --cpus --cpuhotplug --plugcpu
@@ -1663,7 +1975,7 @@ _VBoxManage() {
--macaddress3 --macaddress4 --macaddress5 --macaddress6 --macaddress3 --macaddress4 --macaddress5 --macaddress6
--macaddress7 --macaddress8 --mouse --keyboard --uart1 --uartmode1 --macaddress7 --macaddress8 --mouse --keyboard --uart1 --uartmode1
--uart2 --uartmode2 --lpt1 --lptmode1 --guestmemoryballoon --audio --uart2 --uartmode2 --lpt1 --lptmode1 --guestmemoryballoon --audio
--audiocontroller --clipboard --draganddrop --vrde --vrdeextpack --audiocontroller --clipboard-mode --draganddrop --vrde --vrdeextpack
--vrdeproperty --vrdeport --vrdeaddress --vrdeauthtype --vrdeproperty --vrdeport --vrdeaddress --vrdeauthtype
--vrdeauthlibrary --vrdemulticon --vrdereusecon --vrdevideochannel --vrdeauthlibrary --vrdemulticon --vrdereusecon --vrdevideochannel
--vrdevideochannelquality --usbohci --usbehci --snapshotfolder --vrdevideochannelquality --usbohci --usbehci --snapshotfolder
@@ -1678,7 +1990,8 @@ _VBoxManage() {
--x2apic --paravirtdebug --cpu-profile --biosapic --ibpb-on-vm-entry --x2apic --paravirtdebug --cpu-profile --biosapic --ibpb-on-vm-entry
--ibpb-on-vm-exit --spec-ctrl --audioin --audioout --ibpb-on-vm-exit --spec-ctrl --audioin --audioout
--l1d-flush-on-sched --l1d-flush-on-vm-entry --mds-clear-on-sched --l1d-flush-on-sched --l1d-flush-on-vm-entry --mds-clear-on-sched
--mds-clear-on-vm-entry --nested-hw-virt --uarttype1 --uarttype2) --mds-clear-on-vm-entry --nested-hw-virt --uarttype1 --uarttype2
--system-uuid-le --vm-process-priority)
if [[ ${prev} == ${cmd} ]]; then if [[ ${prev} == ${cmd} ]]; then
_vms_comp vms _vms_comp vms
@@ -1721,7 +2034,7 @@ _VBoxManage() {
--ibpb-on-vm-entry|--ibpb-on-vm-exit|--spec-ctrl|--audioin|\ --ibpb-on-vm-entry|--ibpb-on-vm-exit|--spec-ctrl|--audioin|\
--audioout|--l1d-flush-on-sched|--l1d-flush-on-vm-entry|\ --audioout|--l1d-flush-on-sched|--l1d-flush-on-vm-entry|\
--mds-clear-on-sched|--mds-clear-on-vm-entry|\ --mds-clear-on-sched|--mds-clear-on-vm-entry|\
--nested-hw-virt) --nested-hw-virt|--system-uuid-le)
COMPREPLY=( $(compgen -W "on off" -- ${cur}) ) COMPREPLY=( $(compgen -W "on off" -- ${cur}) )
;; ;;
@@ -1755,8 +2068,8 @@ _VBoxManage() {
;; ;;
--nictype[1-8]) --nictype[1-8])
COMPREPLY=( $(compgen -W "Am79C970A Am79C973 82540EM COMPREPLY=( $(compgen -W "Am79C970A Am79C973 Am79C960
82543GC 82545EM virtio" -- ${cur}) ) 82540EM 82543GC 82545EM virtio" -- ${cur}) )
;; ;;
--nicpromisc[1-8]) --nicpromisc[1-8])
@@ -1849,7 +2162,7 @@ _VBoxManage() {
sb16" -- ${cur}) ) sb16" -- ${cur}) )
;; ;;
--clipboard) --clipboard-mode)
COMPREPLY=( $(compgen -W "disabled hosttoguest COMPREPLY=( $(compgen -W "disabled hosttoguest
guesttohost bidirectional" -- ${cur}) ) guesttohost bidirectional" -- ${cur}) )
;; ;;
@@ -1896,6 +2209,10 @@ _VBoxManage() {
--nattftpfile[1-8]) --nattftpfile[1-8])
COMPREPLY=( $(compgen -f -- ${cur}) ) COMPREPLY=( $(compgen -f -- ${cur}) )
;; ;;
--vm-process-priority)
COMPREPLY=( $(compgen -W "default flat low normal high" \
-- ${cur}) )
;;
esac esac
fi fi
;; ;;
@@ -2028,7 +2345,7 @@ _VBoxManage() {
case "${subcommand}" in case "${subcommand}" in
add) add)
items=(--name --hostpath --transient --readonly items=(--name --hostpath --transient --readonly
--automount) --automount --auto-mount-point)
_get_excluded_items "${items[@]}" _get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) ) COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;; ;;
@@ -2127,8 +2444,16 @@ _VBoxManage() {
;; ;;
esac esac
else else
[[ ${#COMPREPLY[@]} -eq 0 ]] && \ case "$prev" in
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) ) --uniquename)
COMPREPLY=( $(compgen -W "Number Timestamp Space
Force" -- ${cur}) )
;;
*)
[[ ${#COMPREPLY[@]} -eq 0 ]] && \
COMPREPLY=( $(compgen -W "${items[*]}" \
-- ${cur}) )
esac
fi fi
fi fi
;; ;;