10 Commits

6 changed files with 567 additions and 131 deletions

24
LICENSE Normal file
View File

@@ -0,0 +1,24 @@
Copyright (c) 2015, Roman Dobosz
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the organization nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL ROMAN DOBOSZ BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

8
README
View File

@@ -1,8 +0,0 @@
VBoxManage bash completion script.
This version of the completion was initially based on Sebastian T. Hafner
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
4.3.28, and supports all commands (in some extent ;)).

56
README.rst Normal file
View File

@@ -0,0 +1,56 @@
VBoxManage bash completion script
=================================
This version of the completion was initially based on Sebastian T. Hafner
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.40, 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:
.. image:: /images/vboxmanage_session.gif?raw=true
:alt: VBoxManage session
Note, that ``startvm`` command proposes only VMs, which are not running, while
``controlvm`` will complete only running VMs.
What is worth to mention, this completion script is a real thing, so it only
offer things which have sense for particular commands, for example:
.. image:: /images/vboxmanage_snapshot.gif?raw=true
:alt: Take a snapshot
For ``snapshot take`` subcommand, the only options which are proposed are
``--live`` and ``--description``. Other commands and subcommands are behaving in
similar way.
Installation
============
Either source the file::
$ . /path/to/this/repo/VBoxManage
or add it to a proper place depending on your distribution. Usual place would
be:
* ~/bash-completion.d/
* /usr/local/etc/bash-completion.d/
* /etc/bash_completion.d/
* etc.
It's also okay to copy it into some directory, and place proper line in
``.profile`` or ``.bashrc``::
source /some/directory/VBoxManage
License
=======
This software is licensed under 3-clause BSD license. See LICENSE file for
details.

View File

@@ -1,6 +1,9 @@
# bash command-line completion for VBoxManage command
#
# Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
# 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)
_VBoxManage() {
local cur prev opts cmd subcommand tmp items name index result
@@ -101,10 +104,24 @@ _VBoxManage() {
# Issues are the same as in above function.
_vms_comp() {
local command=$1
local exclude_running=false
local vms
local running_vms
local item
compopt -o filenames
if [[ $# == 2 ]]
then
exclude_running=true
running_vms=$(VBoxManage list runningvms | \
awk -F ' {' '{ print $1 }' | \
tr '\n' '|' | \
sed 's/|$//' | \
sed 's/"//g')
IFS='|' read -ra running_vms <<< "$running_vms"
fi
vms=$(VBoxManage list $command | \
awk -F ' {' '{ print $1 }' | \
tr '\n' '|' | \
@@ -113,6 +130,12 @@ _VBoxManage() {
IFS='|' read -ra vms <<< "$vms"
for item in "${vms[@]}"
do
if $exclude_running
then
_is_in_array "$item" "${running_vms[@]}"
[[ $? == 0 ]] && continue
fi
[[ ${item^^} == ${cur^^}* ]] && COMPREPLY+=("$item")
done
}
@@ -369,6 +392,33 @@ _VBoxManage() {
done
}
_is_in_array() {
local element
for element in "${@:2}"
do
[[ "$element" == "$1" ]] && return 0
done
return 1
}
# search for the word before current one, and try to match apropriate item
# to be displayed
# for example:
# foo bar disk baz
# will search for word disk.
_get_medium () {
case "${COMP_WORDS[COMP_CWORD-2]}" in
disk)
_hdd_comp
;;
dvd)
_dvds_comp
;;
floppy)
_floppy_comp
;;
esac
}
COMP_WORDBREAKS=${COMP_WORDBREAKS//|/} # remove pipe from comp word breaks
COMPREPLY=()
@@ -402,6 +452,7 @@ _VBoxManage() {
[[ -z "${name}" ]] &&
_vms_state_comp
;;
bandwidthctl)
local items=(add set remove list)
if [[ ${prev} == ${cmd} ]]; then
@@ -448,10 +499,29 @@ _VBoxManage() {
fi
fi
;;
clonehd)
checkmediumpwd)
if [[ ${prev} == ${cmd} ]]; then
_hdd_comp
_floppy_comp
_dvds_comp
fi
;;
clonemedium)
if [[ ${prev} == ${cmd} ]]; then
COMPREPLY=( $(compgen -W "disk dvd floppy" -- ${cur}) )
else
case "${prev}" in
disk)
_hdd_comp
;;
dvd)
_dvds_comp
;;
floppy)
_floppy_comp
;;
*)
_find_item_name 2
items=(--format --variant --existing)
_get_excluded_items "${items[@]}"
@@ -459,15 +529,19 @@ _VBoxManage() {
case "${prev}" in
--format)
COMPREPLY=( $(compgen -W "VDI VMDK VHD RAW" -- ${cur}) )
COMPREPLY=( $(compgen -W "VDI VMDK VHD RAW" --\
${cur}) )
;;
--variant)
COMPREPLY=( $(compgen -W "Standard Fixed Split2G Stream
ESX" -- ${cur}) )
COMPREPLY=( $(compgen -W "Standard Fixed Split2G
Stream ESX" -- ${cur}) )
;;
esac
;;
esac
fi
;;
clonevm)
if [[ ${prev} == ${cmd} ]]; then
_vms_comp vms
@@ -500,9 +574,13 @@ _VBoxManage() {
esac
fi
;;
closemedium)
if [[ ${prev} == ${cmd} ]]; then
COMPREPLY=( $(compgen -W "disk dvd floppy" -- ${cur}) )
_hdd_comp
_dvds_comp
_floppy_comp
else
case "${prev}" in
disk)
@@ -522,6 +600,7 @@ _VBoxManage() {
esac
fi
;;
controlvm)
if [[ ${prev} == ${cmd} ]]; then
_vms_comp runningvms
@@ -540,8 +619,12 @@ _VBoxManage() {
screenshotpng setcredentials setlinkstate1 setlinkstate2
setlinkstate3 setlinkstate4 setlinkstate5 setlinkstate6
setlinkstate7 setlinkstate8 setvideomodehint teleport unplugcpu
usbattach usbdetach vcpenabled vcpscreens vrde vrdeport
vrdeproperty vrdevideochannelquality webcam)
usbattach usbdetach vrde vrdeport vrdeproperty
vrdevideochannelquality webcam videocap videocapscreens
videocapfile videocapres videocaprate videocapfps
videocapmaxtime videocapmaxsize addencpassword removeencpassword
removeallencpasswords)
_find_item_name 2
subcommand=${COMP_WORDS[$((index+1))]}
@@ -585,13 +668,13 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "disabled
hosttoguest" -- ${cur}) )
;;
vrde|vcpenabled)
vrde|videocap)
[[ ${prev} == "vrde" ||
${prev} == "vcpenabled" ]] && \
${prev} == "videocap" ]] && \
COMPREPLY=( $(compgen -W "on off" -- ${cur}) )
;;
vcpscreens)
[[ ${prev} == "vcpscreens" ]] && \
videocapscreens)
[[ ${prev} == "videocapscreens" ]] && \
COMPREPLY=( $(compgen -W "all none" -- ${cur}) )
;;
setcredentials)
@@ -614,6 +697,22 @@ _VBoxManage() {
[[ ${prev} == "attach" ]] && \
_webcam_avail_comp
;;
usbattach)
tmp=(--capturefile)
_get_excluded_items "${tmp[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
--removeonsuspend)
COMPREPLY=( $(compgen -W "yes no" -- ${cur}) )
;;
addencpassword)
tmp=(--host --port --maxdowntime --passwordfile
--password)
_get_excluded_items "${tmp[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
esac
else
[[ ${#COMPREPLY[@]} -eq 0 ]] && \
@@ -621,6 +720,7 @@ _VBoxManage() {
fi
fi
;;
convertfromraw)
local items=(--format --variant --uuid)
@@ -640,11 +740,17 @@ _VBoxManage() {
esac
fi
;;
createhd)
createmedium)
items=(--filename --size --sizebyte --diffparent --format --variant)
if [[ ${prev} == ${cmd} ]]; then
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
COMPREPLY=( $(compgen -W "disk dvd floppy" -- ${cur}) )
else
case "${prev}" in
disk|dvd|floppy)
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
;;
*)
[[ " ${COMP_WORDS[@]} " == *" --size "* ||
" ${COMP_WORDS[@]} " == *" --sizebyte "* ]] &&
items=(--filename --diffparent --format --variant)
@@ -660,15 +766,19 @@ _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" -- ${cur}) )
COMPREPLY=( $(compgen -W "Standard Fixed Split2G
Stream ESX" -- ${cur}) )
;;
esac
;;
esac
fi
;;
createvm)
items=(--name --groups --ostype --register --basefolder --uuid)
if [[ ${prev} == ${cmd} ]]; then
@@ -696,9 +806,10 @@ _VBoxManage() {
esac
fi
;;
debugvm)
items=(dumpguestcore info injectnmi log logdest logflags osdetect
osinfo getregisters setregisters show statistics)
osinfo osdmesg getregisters setregisters show statistics)
if [[ ${prev} == ${cmd} ]]; then
_vms_comp runningvms
else
@@ -730,6 +841,14 @@ _VBoxManage() {
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
osdmesg)
items=()
[[ " ${COMP_WORDS[@]} " != *" --lines "* &&
" ${COMP_WORDS[@]} " != *" -n "* ]] &&
items+=(--lines -n)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
esac
_get_excluded_items "--descriptions"
COMPREPLY+=( $(compgen -W "$result" -- ${cur}) )
@@ -741,6 +860,7 @@ _VBoxManage() {
fi
fi
;;
dhcpserver)
items=(add modify remove)
subcommand=${COMP_WORDS[2]}
@@ -785,12 +905,26 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
fi
;;
discardstate)
_find_item_name 2
COMPREPLY=()
[[ -z "${name}" ]] &&
_vms_state_comp
;;
encryptmedium)
if [[ ${prev} == ${cmd} ]]; then
_hdd_comp
_floppy_comp
_dvds_comp
else
COMPREPLY=( $(compgen -W "--newpassword --oldpassword --cipher
--newpasswordid" -- ${cur}) )
fi
;;
"export")
items=( --manifest --iso --options --vsys)
if [[ ${prev} == ${cmd} ]]; then
@@ -820,6 +954,7 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
fi
;;
extpack)
items=(install uninstall cleanup)
subcommand=${COMP_WORDS[2]}
@@ -845,6 +980,7 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
fi
;;
getextradata)
if [[ ${prev} == ${cmd} ]]; then
COMPREPLY=( $(compgen -W "global" -- ${cur}) )
@@ -854,11 +990,13 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
fi
;;
guestcontrol)
local items=(execute copyfrom copyto cp createdir createdirectory
mkdir md removedir removedirectory rmdir removefile rm ren rename mv
createtemp createtemporary mktemp list process pskill kill session
stat updateadditions watch)
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
_vms_comp runningvms
@@ -867,81 +1005,213 @@ _VBoxManage() {
subcommand=${COMP_WORDS[$((index+1))]}
if [[ " ${items[@]} " == *" $subcommand "* ]]; then
case "${subcommand}" in
exec|execute)
items=(--image --username --passwordfile --password
--domain --verbose --timeout --environment
--wait-exit --wait-stdout --wait-stderr --dos2unix
--unix2dos)
run)
items=(--exe --timeout --unquoted-args
--ignore-operhaned-processes --no-profile
--dos2unix --unix2dos --username --domain --)
[[ " ${COMP_WORDS[@]} " == *" --password "* ||
" ${COMP_WORDS[@]} " == *" --passwordfile "* ]] &&
items=(--image --username --domain --verbose
--timeout --environment --wait-exit --wait-stdout
--wait-stderr --dos2unix --unquoted-args
--unix2dos)
[[ " ${comp_words[@]} " != *" --password "* ||
" ${comp_words[@]} " != *" --passwordfile "* ]] &&
items+=(--passwordfile --password)
[[ " ${COMP_WORDS[@]} " != *" --putenv "* &&
" ${COMP_WORDS[@]} " != *" -E "* ]] &&
items+=(--putenv -E)
[[ " ${COMP_WORDS[@]} " != *" --no-wait-stdout "* &&
" ${COMP_WORDS[@]} " != *" --wait-stdout "* ]] &&
items+=(--no-wait-stdout --wait-stdout)
[[ " ${COMP_WORDS[@]} " != *" --no-wait-stderr"* &&
" ${COMP_WORDS[@]} " != *" --wait-stderr "* ]] &&
items+=(--no-wait-stderr --wait-stderr)
[[ " ${COMP_WORDS[@]} " != *" --verbose "* &&
" ${COMP_WORDS[@]} " != *" -v "* ]] &&
items+=(--verbose -v)
[[ " ${COMP_WORDS[@]} " != *" --quiet "* &&
" ${COMP_WORDS[@]} " != *" -q "* ]] &&
items+=(--quiet -q)
_get_excluded_items "${items[@]}"
compreply=( $(compgen -w "$result" -- ${cur}) )
;;
start)
items=(--exe --timeout --unquoted-args
--ignore-operhaned-processes --no-profile
--username --domain --passwordfile --password --)
[[ " ${comp_words[@]} " != *" --password "* ||
" ${comp_words[@]} " != *" --passwordfile "* ]] &&
items+=(--passwordfile --password)
[[ " ${COMP_WORDS[@]} " != *" --verbose "* &&
" ${COMP_WORDS[@]} " != *" -v "* ]] &&
items+=(--verbose -v)
[[ " ${COMP_WORDS[@]} " != *" --quiet "* &&
" ${COMP_WORDS[@]} " != *" -q "* ]] &&
items+=(--quiet -q)
_get_excluded_items "${items[@]}"
compreply=( $(compgen -w "$result" -- ${cur}) )
;;
copyfrom|copyto)
items=(--dryrun --follow --target-directory
--username --domain)
[[ " ${COMP_WORDS[@]} " != *" --recursive "* &&
" ${COMP_WORDS[@]} " != *" -R "* ]] &&
items+=(--recursive -R)
[[ " ${comp_words[@]} " != *" --password "* ||
" ${comp_words[@]} " != *" --passwordfile "* ]] &&
items+=(--passwordfile --password)
[[ " ${COMP_WORDS[@]} " != *" --verbose "* &&
" ${COMP_WORDS[@]} " != *" -v "* ]] &&
items+=(--verbose -v)
[[ " ${COMP_WORDS[@]} " != *" --quiet "* &&
" ${COMP_WORDS[@]} " != *" -q "* ]] &&
items+=(--quiet -q)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
copyfrom|copyto|cp)
items=(--username --passwordfile --password
--domain --verbose --dryrun --follow --recursive)
[[ " ${COMP_WORDS[@]} " == *" --password "* ||
" ${COMP_WORDS[@]} " == *" --passwordfile "* ]] &&
items=(--username --domain --verbose --dryrun
--follow --recursive)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
createdirectory|createdir|mkdir|md)
items=(--username --passwordfile --password
--domain --verbose --parents --mode)
[[ " ${COMP_WORDS[@]} " == *" --password "* ||
" ${COMP_WORDS[@]} " == *" --passwordfile "* ]] &&
items=(--username --domain --verbose --parents
--mode)
createdirectory|createdir|mkdir)
items=(--parents --mode --username --domain)
[[ " ${COMP_WORDS[@]} " != *" --password "* ||
" ${COMP_WORDS[@]} " != *" --passwordfile "* ]] &&
items+=(--passwordfile --password)
[[ " ${COMP_WORDS[@]} " != *" --verbose "* &&
" ${COMP_WORDS[@]} " != *" -v "* ]] &&
items+=(--verbose -v)
[[ " ${COMP_WORDS[@]} " != *" --quiet "* &&
" ${COMP_WORDS[@]} " != *" -q "* ]] &&
items+=(--quiet -q)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
removedir|removedirectory|rmdir)
items=(--username --domain --verbose)
items=(--username --domain)
[[ " ${COMP_WORDS[@]} " != *" --password "* &&
" ${COMP_WORDS[@]} " != *" --passwordfile "* ]] &&
items+=(--passwordfile --password)
[[ " ${COMP_WORDS[@]} " != *" --recursive "* &&
" ${COMP_WORDS[@]} " != *" -R "* &&
" ${COMP_WORDS[@]} " != *" -r "* ]] &&
items+=(--recursive -R -r)
" ${COMP_WORDS[@]} " != *" -R "* ]] &&
items+=(--recursive -R)
[[ " ${COMP_WORDS[@]} " != *" --verbose "* &&
" ${COMP_WORDS[@]} " != *" -v "* ]] &&
items+=(--verbose -v)
[[ " ${COMP_WORDS[@]} " != *" --quiet "* &&
" ${COMP_WORDS[@]} " != *" -q "* ]] &&
items+=(--quiet -q)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
removefile|rm|rename|ren|mv)
items=(--username --domain --verbose)
removefile|rm)
items=(--username --domain)
[[ " ${COMP_WORDS[@]} " != *" --force "* &&
" ${COMP_WORDS[@]} " != *" -f "* ]] &&
items+=(--force -f)
[[ " ${COMP_WORDS[@]} " != *" --password "* &&
" ${COMP_WORDS[@]} " != *" --passwordfile "* ]] &&
items+=(--passwordfile --password)
[[ " ${COMP_WORDS[@]} " != *" --verbose "* &&
" ${COMP_WORDS[@]} " != *" -v "* ]] &&
items+=(--verbose -v)
[[ " ${COMP_WORDS[@]} " != *" --quiet "* &&
" ${COMP_WORDS[@]} " != *" -q "* ]] &&
items+=(--quiet -q)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
rename|ren|move|mv)
items=(--username --domain)
[[ " ${COMP_WORDS[@]} " != *" --password "* &&
" ${COMP_WORDS[@]} " != *" --passwordfile "* ]] &&
items+=(--passwordfile --password)
[[ " ${COMP_WORDS[@]} " != *" --verbose "* &&
" ${COMP_WORDS[@]} " != *" -v "* ]] &&
items+=(--verbose -v)
[[ " ${COMP_WORDS[@]} " != *" --quiet "* &&
" ${COMP_WORDS[@]} " != *" -q "* ]] &&
items+=(--quiet -q)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
createtemporary|createtemp|mktemp)
items=(--username --domain --verbose --directory
--secure --tmpdir --mode)
items=(--username --domain --secure --tmpdir --mode)
[[ " ${COMP_WORDS[@]} " != *" --password "* &&
" ${COMP_WORDS[@]} " != *" --passwordfile "* ]] &&
items+=(--passwordfile --password)
[[ " ${COMP_WORDS[@]} " != *" --verbose "* &&
" ${COMP_WORDS[@]} " != *" -v "* ]] &&
items+=(--verbose -v)
[[ " ${COMP_WORDS[@]} " != *" --quiet "* &&
" ${COMP_WORDS[@]} " != *" -q "* ]] &&
items+=(--quiet -q)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
list)
items=(--verbose)
items=()
[[ " ${COMP_WORDS[@]} " != *" all "* &&
" ${COMP_WORDS[@]} " != *" sessions "* &&
" ${COMP_WORDS[@]} " != *" processes "* &&
" ${COMP_WORDS[@]} " != *" files "* ]] &&
items+=(all sessions processes files)
[[ " ${COMP_WORDS[@]} " != *" --verbose "* &&
" ${COMP_WORDS[@]} " != *" -v "* ]] &&
items+=(--verbose -v)
[[ " ${COMP_WORDS[@]} " != *" --quiet "* &&
" ${COMP_WORDS[@]} " != *" -q "* ]] &&
items+=(--quiet -q)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
closeprocess)
items=()
[[ " ${COMP_WORDS[@]} " != *" --verbose "* &&
" ${COMP_WORDS[@]} " != *" -v "* ]] &&
items+=(--verbose -v)
[[ " ${COMP_WORDS[@]} " != *" --quiet "* &&
" ${COMP_WORDS[@]} " != *" -q "* ]] &&
items+=(--quiet -q)
[[ " ${COMP_WORDS[@]} " != *" --session-id "* ]] &&
items+=(--session-name)
[[ " ${COMP_WORDS[@]} " != *" --session-name "* ]] &&
items+=(--session-id)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
closesession)
items=()
[[ " ${COMP_WORDS[@]} " != *" --verbose "* &&
" ${COMP_WORDS[@]} " != *" -v "* ]] &&
items+=(--verbose -v)
[[ " ${COMP_WORDS[@]} " != *" --quiet "* &&
" ${COMP_WORDS[@]} " != *" -q "* ]] &&
items+=(--quiet -q)
[[ " ${COMP_WORDS[@]} " != *" --session-id "* &&
" ${COMP_WORDS[@]} " != *" --session-name "* &&
" ${COMP_WORDS[@]} " != *" --all "* ]] &&
items+=(--session-id --session-name --all)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
process)
if [[ " ${COMP_WORDS[@]} " == *" process kill "* ]];
then
@@ -956,18 +1226,7 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
fi
;;
pskill|pkill|kill)
items=(--verbose)
[[ " ${COMP_WORDS[@]} " != *" --session-name "* &&
" ${COMP_WORDS[@]} " != *" --session-id "* ]] &&
items+=(--session-id --session-name)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
session)
_get_excluded_items "close"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
stat)
if [[ "${cur}" == "stat" ]]; then
COMPREPLY=( $(compgen -- ${cur}) )
@@ -976,16 +1235,38 @@ _VBoxManage() {
[[ " ${COMP_WORDS[@]} " != *" --password "* &&
" ${COMP_WORDS[@]} " != *" --passwordfile "* ]] &&
items+=(--passwordfile --password)
[[ " ${COMP_WORDS[@]} " != *" --verbose "* &&
" ${COMP_WORDS[@]} " != *" -v "* ]] &&
items+=(--verbose -v)
[[ " ${COMP_WORDS[@]} " != *" --quiet "* &&
" ${COMP_WORDS[@]} " != *" -q "* ]] &&
items+=(--quiet -q)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
fi
;;
updateadditions)
items=(--source --verbose --wait-start)
updatega|updateguestadditions|updateadditions)
items=(--source --wait-start)
[[ " ${COMP_WORDS[@]} " != *" --verbose "* &&
" ${COMP_WORDS[@]} " != *" -v "* ]] &&
items+=(--verbose -v)
[[ " ${COMP_WORDS[@]} " != *" --quiet "* &&
" ${COMP_WORDS[@]} " != *" -q "* ]] &&
items+=(--quiet -q)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
watch)
items=()
[[ " ${COMP_WORDS[@]} " != *" --verbose "* &&
" ${COMP_WORDS[@]} " != *" -v "* ]] &&
items+=(--verbose -v)
[[ " ${COMP_WORDS[@]} " != *" --quiet "* &&
" ${COMP_WORDS[@]} " != *" -q "* ]] &&
items+=(--quiet -q)
_get_excluded_items "--verbose"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
@@ -1021,6 +1302,7 @@ _VBoxManage() {
fi
fi
;;
guestproperty)
items=(get set delete unset enumerate wait)
subcommand=${COMP_WORDS[2]}
@@ -1052,6 +1334,7 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
fi
;;
hostonlyif)
items=(ipconfig create remove)
subcommand=${COMP_WORDS[2]}
@@ -1085,6 +1368,7 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
fi
;;
import)
items=(--options)
if [[ "${prev}" == "import" ]]; then
@@ -1093,8 +1377,8 @@ _VBoxManage() {
else
case "${prev}" in
--options)
COMPREPLY=( $(compgen -W "keepallmacs keepnatmacs" \
-- ${cur}) )
COMPREPLY=( $(compgen -W "keepallmacs keepnatmacs
importtovdi" -- ${cur}) )
;;
esac
[[ " ${COMP_WORDS[@]} " != *" --dry-run"* &&
@@ -1107,6 +1391,7 @@ _VBoxManage() {
fi
fi
;;
list)
if [[ ${prev} == ${cmd} ]]; then
_list_comp ${cur}
@@ -1121,6 +1406,22 @@ _VBoxManage() {
esac
fi
;;
mediumproperty)
if [[ ${prev} == ${cmd} ]]; then
COMPREPLY=( $(compgen -W "disk dvd floppy" -- ${cur}) )
else
case "${prev}" in
disk|dvd|floppy)
COMPREPLY=( $(compgen -W "get set delete" -- ${cur}) )
;;
get|set|floppy)
_get_medium
;;
esac
fi
;;
metrics)
items=(list setup query enable disable collect)
subcommand=${COMP_WORDS[2]}
@@ -1177,30 +1478,46 @@ _VBoxManage() {
fi
;;
modifyhd)
modifymedium)
if [[ ${prev} == ${cmd} ]]; then
_hdd_comp
COMPREPLY=( $(compgen -W "disk dvd floppy" -- ${cur}) )
else
case "${prev}" in
disk)
_hdd_comp
;;
dvd)
_dvds_comp
;;
floppy)
_floppy_comp
;;
*)
_find_item_name 2
items=(--type --autoreset --property --compact --resize)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
case "${prev}" in
--type)
COMPREPLY=( $(compgen -W "normal writethrough immutable
shareable readonly multiattach" -- ${cur}) )
COMPREPLY=( $(compgen -W "normal writethrough
immutable shareable readonly multiattach" --\
${cur}) )
;;
--autoreset)
COMPREPLY=( $(compgen -W "on off" -- ${cur}) )
;;
esac
;;
esac
fi
;;
modifyvm)
items=(--name --groups --description --ostype --iconfile --memory
--pagefusion --vram --acpi --pciattach --pcidetach --ioapic --hpet
--triplefaultreset --hwvirtex --nestedpaging --largepages --vtxvpid
--vtxux --pae --longmode --synthcpu --cpuidset --cpuidremove
--vtxux --pae --longmode --cpuidset --cpuidremove
--cpuidremoveall --hardwareuuid --cpus --cpuhotplug --plugcpu
--unplugcpu --cpuexecutioncap --rtcuseutc --graphicscontroller
--monitorcount --accelerate3d --accelerate2dvideo --firmware
@@ -1264,9 +1581,11 @@ _VBoxManage() {
--teleporter --teleporterport --teleporteraddress
--teleporterpassword --teleporterpasswordfile --tracing-enabled
--tracing-config --tracing-allow-vm-access --usbcardreader
--autostart-enabled --autostart-delay --vcpenabled --vcpscreens
--vcpfile --vcpwidth --vcpheight --vcprate --vcpfps
--defaultfrontend)
--autostart-enabled --autostart-delay --videocap --videocapscreens
--videocapfile --videocapres --videocaprate --videocapfps
--videocapmaxtime --videocapmaxsize --videocapopts --defaultfrontend
--cpuid-portability-level --paravirtprovider --audiocodec --usbxhci
--usbrename)
if [[ ${prev} == ${cmd} ]]; then
_vms_comp vms
@@ -1284,7 +1603,7 @@ _VBoxManage() {
;;
--pagefusion|--acpi|--ioapic|--hpet|--triplefaultreset|\
--hwvirtex|--nestedpaging|--largepages|--vtxvpid|--vtxux|\
--pae|--longmode|--synthcpu|--cpuhotplug|--rtcuseutc|\
--pae|--longmode|--cpuhotplug|--rtcuseutc|\
--accelerate3d|--accelerate2dvideo|--bioslogofadein|\
--bioslogofadeout|--biospxedebug|--cableconnected1|\
--cableconnected2|--cableconnected3|--cableconnected4|\
@@ -1303,7 +1622,7 @@ _VBoxManage() {
--vrdemulticon|--vrdereusecon|--vrdevideochannel|--usb|\
--usbehci|--teleporter|--tracing-enabled|\
--tracing-allow-vm-access|--usbcardreader|\
--autostart-enabled|--vcpenabled)
--autostart-enabled|--videocap|--usbxhci)
COMPREPLY=( $(compgen -W "on off" -- ${cur}) )
;;
--graphicscontroller)
@@ -1390,7 +1709,7 @@ _VBoxManage() {
;;
--uartmode[1-2])
COMPREPLY+=( $(compgen -W "disconnected server client
file" -- ${cur}) )
tcpserver tcpclient file" -- ${cur}) )
;;
--audio)
COMPREPLY+=( $(compgen -W "none null oss alsa pulse" \
@@ -1401,6 +1720,11 @@ _VBoxManage() {
COMPREPLY+=( $(compgen -W "ac97 hda sb16" -- ${cur}) )
;;
--audiocodec)
COMPREPLY+=( $(compgen -W "stac9700 ad1980 stac9221
sb16" -- ${cur}) )
;;
--clipboard)
COMPREPLY+=( $(compgen -W "disabled hosttoguest
guesttohost bidirectional" -- ${cur}) )
@@ -1418,9 +1742,17 @@ _VBoxManage() {
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}) )
;;
esac
fi
;;
natnetwork)
items=(add remove modify start stop)
subcommand=${COMP_WORDS[2]}
@@ -1451,6 +1783,7 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
fi
;;
registervm)
if [[ ${prev} == ${cmd} ]]; then
bind 'set mark-directories on'
@@ -1461,16 +1794,18 @@ _VBoxManage() {
COMPREPLY[0]="${COMPREPLY[0]}/"
fi
;;
setextradata)
if [[ ${prev} == ${cmd} ]]; then
COMPREPLY=( $(compgen -W "global" -- ${cur}) )
_vms_comp vms
fi
;;
setproperty)
items=(machinefolder hwvirtexclusive vrdeauthlibrary
websrvauthlibrary vrdeextpack autostartdbpath loghistorycount
defaultfrontend)
defaultfrontend logginglevel)
subcommand=${COMP_WORDS[2]}
if [[ "${prev}" == "${cmd}" ]]; then
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
@@ -1500,6 +1835,7 @@ _VBoxManage() {
esac
fi
;;
sharedfolder)
items=(add remove)
subcommand=${COMP_WORDS[2]}
@@ -1536,11 +1872,32 @@ _VBoxManage() {
[[ ${#COMPREPLY[@]} -eq 0 ]] && \
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
;;
showhdinfo)
showmediuminfo)
if [[ ${prev} == ${cmd} ]]; then
COMPREPLY=( $(compgen -W "disk dvd floppy" -- ${cur}) )
_hdd_comp
_dvds_comp
_floppy_comp
else
case "${prev}" in
disk)
_hdd_comp
;;
dvd)
_dvds_comp
;;
floppy)
_floppy_comp
;;
*)
items=(--delete)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
esac
fi
;;
showvminfo)
if [[ ${prev} == ${cmd} ]]; then
_vms_comp vms
@@ -1559,6 +1916,7 @@ _VBoxManage() {
fi
fi
;;
snapshot)
items=(take delete restore restorecurrent edit list showvminfo)
if [[ ${prev} == ${cmd} ]]; then
@@ -1569,7 +1927,7 @@ _VBoxManage() {
if [[ " ${items[@]} " == *" $subcommand "* ]]; then
case "${subcommand}" in
take)
items=(--description --live)
items=(--description --live --uniquename)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
@@ -1602,17 +1960,19 @@ _VBoxManage() {
fi
fi
;;
startvm)
if [[ ${prev} == ${cmd} ]]; then
_vms_comp vms
_vms_comp vms 1
elif [[ "${prev}" == "--type" ]]; then
COMPREPLY=( $(compgen -W "gui sdl headless" -- ${cur}) )
COMPREPLY=( $(compgen -W "gui sdl headless separate" -- ${cur}) )
else
local items=(--type)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
fi
;;
storageattach)
if [[ ${prev} == ${cmd} ]]; then
_vms_comp vms
@@ -1620,9 +1980,9 @@ _VBoxManage() {
_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)
--nonrotational --discard --hotpluggable --bandwidthgroup
--forceunmount --server --target --tport --lun --encodedlun
--username --password --initiator --intnet)
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
@@ -1651,9 +2011,10 @@ _VBoxManage() {
esac
fi
;;
storagectl)
local items=(--name --add --controller --portcount --hostiocache
--bootable --remove)
--bootable --rename --remove)
if [[ ${prev} == ${cmd} ]]; then
_vms_comp vms
else
@@ -1674,6 +2035,7 @@ _VBoxManage() {
esac
fi
;;
unregistervm)
if [[ ${prev} == ${cmd} ]]; then
_vms_comp vms
@@ -1683,7 +2045,8 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
fi
;;
usbfilter)
usbfilte)
if [[ COMP_CWORD -ge 3 ]]; then
subcommand="${COMP_WORDS[2]}"
if [[ $subcommand == "${cmd}" ]]; then
@@ -1727,5 +2090,6 @@ _VBoxManage() {
esac
}
complete -o default -F _VBoxManage VBoxManage
complete -o default -F _VBoxManage vboxmanage
# vim: set ft=sh tw=80 sw=4 et :

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 KiB