7 Commits

Author SHA1 Message Date
3efab392c1 Bump to 7.0.12 2024-02-12 21:17:24 +01:00
b0352554bb Merge pull request #14 from mattalexx/patch-1
Use `grep -E` instead of `egrep` to suppress warnings
2024-02-12 21:15:01 +01:00
Matt Alexander
95088850b6 Use grep -E instead of egrep to suppress warnings
The messages were getting in the way:
```
 $ VBoxManage createvm --name=Win10-3 --ostype Wegrep: warning: egrep is obsolescent; using grep -E
indowsegrep: warning: egrep is obsolescent; using grep -E
egrep: warning: egrep is obsolescent; using grep -E

Windows10        Windows2000      Windows2008      Windows2016_64   Windows31        Windows8         Windows8_64      WindowsMe        WindowsNT4       WindowsVista_64
Windows10_64     Windows2003      Windows2008_64   Windows2019_64   Windows7         Windows81        Windows95        WindowsNT        WindowsNT_64     WindowsXP
Windows11_64     Windows2003_64   Windows2012_64   Windows2022_64   Windows7_64      Windows81_64     Windows98        WindowsNT3x      WindowsVista     WindowsXP_64
matt@q ~ $ VBoxManage createvm --name=Win10-3 --ostype Windowsegrep: warning: egrep is obsolescent; using grep -E

Windows10        Windows2000      Windows2008      Windows2016_64   Windows31        Windows8         Windows8_64      WindowsMe        WindowsNT4       WindowsVista_64
Windows10_64     Windows2003      Windows2008_64   Windows2019_64   Windows7         Windows81        Windows95        WindowsNT        WindowsNT_64     WindowsXP
Windows11_64     Windows2003_64   Windows2012_64   Windows2022_64   Windows7_64      Windows81_64     Windows98        WindowsNT3x      WindowsVista     WindowsXP_64
```
2024-02-12 05:06:39 -06:00
3404afa441 Added support for other names than vboxmanage.
Currently the completion script will be available for commands:
VBoxManage and vboxmanage. With this commit, renaming/linking this
script with another name will also make that name to be included to
completion.

For example, with alias:

    $ alias vb="VBoxManage"

linkig completion script into new name an source it:

    $ cd /path/of/completion/script/
    $ ln -s VBoxManage vb
    # source vb

will start to complete vb command.
2023-11-02 18:14:29 +01:00
ab6d9f7cd9 Added missing completions for cloud related commands.
Also, removed trailing spaces.
2023-11-02 18:11:41 +01:00
3bb795a1e3 Bump to 7.0.10 2023-09-11 10:30:29 +02:00
468a0a4c32 Bump to 7.0.8 2023-06-23 18:26:15 +02:00
2 changed files with 73 additions and 54 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
7.0.6, and should contain all commands and their options. 7.0.12, 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

@@ -1,10 +1,9 @@
# bash command-line completion for VBoxManage command # bash command-line completion for VBoxManage command
# #
# Author: Roman 'gryf' Dobosz <gryf73@gmail.com> # Author: Roman 'gryf' Dobosz <gryf73@gmail.com>
# 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: 7.0.6 # Version: 7.0.12
_VBoxManage() { _VBoxManage() {
@@ -164,8 +163,8 @@ _VBoxManage() {
compopt -o filenames compopt -o filenames
vms=$(VBoxManage list vms -l | \ vms=$(VBoxManage list vms -l | \
egrep '^Name|State' | \ grep -E '^Name|State' | \
egrep -B1 'State:\s+saved' | \ grep -E -B1 'State:\s+saved' | \
grep Name |$VBMC_SED 's/Name:\s\+//' | \ grep Name |$VBMC_SED 's/Name:\s\+//' | \
tr '\n' '|' | \ tr '\n' '|' | \
$VBMC_SED 's/|$//' | \ $VBMC_SED 's/|$//' | \
@@ -199,7 +198,7 @@ _VBoxManage() {
local item local item
list=$(VBoxManage list ostypes | \ list=$(VBoxManage list ostypes | \
egrep ^ID: | \ grep -E ^ID: | \
$VBMC_SED 's/ID:\s\+//' | \ $VBMC_SED 's/ID:\s\+//' | \
tr '\n' '|' | \ tr '\n' '|' | \
$VBMC_SED 's/|$//') $VBMC_SED 's/|$//')
@@ -234,7 +233,7 @@ _VBoxManage() {
local item local item
list=$(VBoxManage list hostonlyifs | \ list=$(VBoxManage list hostonlyifs | \
egrep ^Name: | \ grep -E ^Name: | \
$VBMC_SED 's/Name:\s\+//' | \ $VBMC_SED 's/Name:\s\+//' | \
$VBMC_SED 's/\s/\\ /g'| \ $VBMC_SED 's/\s/\\ /g'| \
tr '\n' '|' | \ tr '\n' '|' | \
@@ -377,7 +376,7 @@ _VBoxManage() {
local item local item
list=$(VBoxManage list bridgedifs | \ list=$(VBoxManage list bridgedifs | \
egrep ^Name: | \ grep -E ^Name: | \
$VBMC_SED 's/Name:\s\+//' | \ $VBMC_SED 's/Name:\s\+//' | \
$VBMC_SED 's/\s/\\ /g'| \ $VBMC_SED 's/\s/\\ /g'| \
tr '\n' '|' | \ tr '\n' '|' | \
@@ -395,7 +394,7 @@ _VBoxManage() {
local item local item
list=$(VBoxManage list intnets| \ list=$(VBoxManage list intnets| \
egrep ^Name: | \ grep -E ^Name: | \
$VBMC_SED 's/Name:\s\+//' | \ $VBMC_SED 's/Name:\s\+//' | \
$VBMC_SED 's/\s/\\ /g'| \ $VBMC_SED 's/\s/\\ /g'| \
tr '\n' '|' | \ tr '\n' '|' | \
@@ -677,11 +676,12 @@ _VBoxManage() {
_cloudprofiles_comp _cloudprofiles_comp
;; ;;
list) list)
COMPREPLY=( $(compgen -W "instances images" -- ${cur}) ) COMPREPLY=( $(compgen -W "instances images vnicattachments"
-- ${cur}) )
;; ;;
instance) instance)
COMPREPLY=( $(compgen -W "create info terminate start COMPREPLY=( $(compgen -W "create info terminate start
pause" -- ${cur}) ) pause reset" -- ${cur}) )
;; ;;
image) image)
COMPREPLY=( $(compgen -W "create info delete import COMPREPLY=( $(compgen -W "create info delete import
@@ -692,6 +692,13 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "setup create" -- ${cur}) ) COMPREPLY=( $(compgen -W "setup create" -- ${cur}) )
fi fi
;; ;;
reset)
COMPREPLY=( $(compgen -W "--id" -- ${cur}) )
;;
vnicattachments)
COMPREPLY=( $(compgen -W "--compartment-id --filter"
-- ${cur}) )
;;
esac esac
if [[ " ${COMP_WORDS[*]} " == *" list images"* || if [[ " ${COMP_WORDS[*]} " == *" list images"* ||
" ${COMP_WORDS[*]} " == *" list instances"* ]]; then " ${COMP_WORDS[*]} " == *" list instances"* ]]; then
@@ -819,23 +826,21 @@ _VBoxManage() {
changeuartmode1 changeuartmode2 clipboard cpuexecutioncap changeuartmode1 changeuartmode2 clipboard cpuexecutioncap
draganddrop guestmemoryballoon keyboardputfile draganddrop guestmemoryballoon keyboardputfile
keyboardputscancode keyboardputstring natpf1 natpf2 natpf3 keyboardputscancode keyboardputstring natpf1 natpf2 natpf3
natpf4 natpf5 natpf6 natpf7 natpf8 natpf9 natpf1delete natpf4 natpf5 natpf6 natpf7 natpf8 natpf9 nic1 nic2 nic3 nic4
natpf2delete natpf3delete natpf4delete natpf5delete natpf6delete nic5 nic6 nic7 nic8 nicpromisc1 nicpromisc2 nicpromisc3
natpf7delete natpf8delete nic1 nic2 nic3 nic4 nic5 nic6 nic7 nicpromisc4 nicpromisc5 nicpromisc6 nicpromisc7 nicpromisc8
nic8 nicpromisc1 nicpromisc2 nicpromisc3 nicpromisc4 nicpromisc5 nicproperty1 nicproperty2 nicproperty3 nicproperty4 nicproperty5
nicpromisc6 nicpromisc7 nicpromisc8 nicproperty1 nicproperty2 nicproperty6 nicproperty7 nicproperty8 nictrace1 nictrace2
nicproperty3 nicproperty4 nicproperty5 nicproperty6 nicproperty7 nictrace3 nictrace4 nictrace5 nictrace6 nictrace7 nictrace8
nicproperty8 nictrace1 nictrace2 nictrace3 nictrace4 nictrace5 nictracefile1 nictracefile2 nictracefile3 nictracefile4
nictrace6 nictrace7 nictrace8 nictracefile1 nictracefile2 nictracefile5 nictracefile6 nictracefile7 nictracefile8 pause
nictracefile3 nictracefile4 nictracefile5 nictracefile6 plugcpu poweroff reboot recording removeallencpasswords
nictracefile7 nictracefile8 pause plugcpu poweroff reboot removeencpassword reset resume savestate screenshotpng
recording removeallencpasswords removeencpassword reset resume setcredentials setlinkstate1 setlinkstate2 setlinkstate3
savestate screenshotpng setcredentials setlinkstate1 setlinkstate4 setlinkstate5 setlinkstate6 setlinkstate7
setlinkstate2 setlinkstate3 setlinkstate4 setlinkstate5 setlinkstate8 setscreenlayout setvideomodehint shutdown teleport
setlinkstate6 setlinkstate7 setlinkstate8 setscreenlayout unplugcpu usbattach usbdetach vm-process-priority vrde vrdeport
setvideomodehint shutdown teleport unplugcpu usbattach usbdetach vrdeproperty vrdevideochannelquality webcam )
vm-process-priority vrde vrdeport vrdeproperty
vrdevideochannelquality webcam )
_find_item_name 2 _find_item_name 2
subcommand=${COMP_WORDS[$((index+1))]} subcommand=${COMP_WORDS[$((index+1))]}
@@ -932,9 +937,8 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "$result" -- ${cur}) ) COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;; ;;
changeuartmode[1-2]) changeuartmode[1-2])
tmp=(disconnected serverpipe-name clientpipe-name tmp=(disconnected server client tcpserver tcpclient
tcpserverport tcpclienthostname:port filefilename file device-name)
device-name)
_get_excluded_items "${tmp[@]}" _get_excluded_items "${tmp[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) ) COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;; ;;
@@ -1041,8 +1045,8 @@ _VBoxManage() {
;; ;;
createvm) createvm)
items=( --basefolder --ciphercipher --default --group --name --ostype items=( --basefolder --cipher --default --group --name --ostype
--password-idpassword-id --passwordfile --register --uuid ) --password-id --password --register --uuid )
if [[ ${prev} == ${cmd} ]]; then if [[ ${prev} == ${cmd} ]]; then
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
else else
@@ -1061,7 +1065,7 @@ _VBoxManage() {
--basefolder) --basefolder)
COMPREPLY=( $(compgen -o dirnames -- ${cur}) ) COMPREPLY=( $(compgen -o dirnames -- ${cur}) )
;; ;;
--passwordfile) --password)
COMPREPLY=( $(compgen -f -- ${cur}) ) COMPREPLY=( $(compgen -f -- ${cur}) )
;; ;;
esac esac
@@ -1302,7 +1306,7 @@ _VBoxManage() {
if [[ " ${items[*]} " == *" $subcommand "* ]]; then if [[ " ${items[*]} " == *" $subcommand "* ]]; then
case "${subcommand}" in case "${subcommand}" in
addpassword) addpassword)
items=( --passwordfile --password-id ) items=( --password --password-id )
_get_excluded_items "${items[@]}" _get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) ) COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;; ;;
@@ -1313,15 +1317,15 @@ _VBoxManage() {
COMPREPLY=() COMPREPLY=()
;; ;;
setencryption) setencryption)
items=( --old-passwordfile --ciphercipher-identifier items=( --old-password --cipher
--new-passwordfile --new-password-id --force ) --new-password --new-password-id --force )
_get_excluded_items "${items[@]}" _get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) ) COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;; ;;
esac esac
else else
case "$prev" in case "$prev" in
--new-passwordfile|--old-passwordfile|--passwordfile) --new-password|--old-password|--password)
COMPREPLY=( $(compgen -f -- ${cur}) ) COMPREPLY=( $(compgen -f -- ${cur}) )
;; ;;
*) *)
@@ -1428,7 +1432,7 @@ _VBoxManage() {
if [[ " ${items[*]} " == *" $subcommand "* ]]; then if [[ " ${items[*]} " == *" $subcommand "* ]]; then
case "${subcommand}" in case "${subcommand}" in
run) run)
items=( --domain --dos2unix --exe items=( --arg0 --domain --dos2unix --exe
--ignore-operhaned-processes --profile --putenv --ignore-operhaned-processes --profile --putenv
--quiet --timeout --unix2dos --unquoted-args --quiet --timeout --unix2dos --unquoted-args
--username --verbose -- ) --username --verbose -- )
@@ -1448,9 +1452,10 @@ _VBoxManage() {
;; ;;
start) start)
items=( --domain --exe --ignore-orphaned-processes items=( --arg0 --domain --exe
--profile --putenv --quiet --timeout --ignore-orphaned-processes --profile --putenv
--unquoted-args --username --verbose -- ) --quiet --timeout --unquoted-args --username
--verbose -- )
[[ " ${COMP_WORDS[*]} " != *" --password "* || [[ " ${COMP_WORDS[*]} " != *" --password "* ||
" ${COMP_WORDS[*]} " != *" --passwordfile "* ]] && " ${COMP_WORDS[*]} " != *" --passwordfile "* ]] &&
@@ -1873,7 +1878,7 @@ _VBoxManage() {
*) *)
_find_item_name 2 _find_item_name 2
items=( --autoreset --compact --description --move items=( --autoreset --compact --description --move
--property --setlocation --type ) --property --property-file --setlocation --type )
[[ " ${COMP_WORDS[*]} " != *" --resize "* && [[ " ${COMP_WORDS[*]} " != *" --resize "* &&
" ${COMP_WORDS[*]} " != *" --resizebyte"* ]] && " ${COMP_WORDS[*]} " != *" --resizebyte"* ]] &&
items+=( --resizebyte --resize ) items+=( --resizebyte --resize )
@@ -1891,7 +1896,7 @@ _VBoxManage() {
--move) --move)
COMPREPLY=( $(compgen -o dirnames -- ${cur}) ) COMPREPLY=( $(compgen -o dirnames -- ${cur}) )
;; ;;
--setlocation) --setlocation|--property-file)
COMPREPLY=( $(compgen -f -- ${cur}) ) COMPREPLY=( $(compgen -f -- ${cur}) )
;; ;;
esac esac
@@ -1902,7 +1907,7 @@ _VBoxManage() {
modifynvram) modifynvram)
items=( changevar deletevar enrollmssignatures enrollorclpk items=( changevar deletevar enrollmssignatures enrollorclpk
enrollpk inituefivarstore listvars queryvar ) enrollpk enrollmok inituefivarstore listvars queryvar )
# _get_excluded_items "${items[@]}" # _get_excluded_items "${items[@]}"
# COMPREPLY=( $(compgen -W "$result" -- ${cur}) ) # COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
@@ -1923,6 +1928,15 @@ _VBoxManage() {
COMPREPLY=( $(compgen -W "$result" -- ${cur}) ) COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
fi fi
;; ;;
enrollmok)
if [ "${prev}" = "--mok" ]; then
COMPREPLY=( $(compgen -f -- ${cur}) )
else
items=( --mok --owner-uuid )
_get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
fi
;;
queryvar|changevar) queryvar|changevar)
if [ "${prev}" = "--filename" ]; then if [ "${prev}" = "--filename" ]; then
COMPREPLY=( $(compgen -f -- ${cur}) ) COMPREPLY=( $(compgen -f -- ${cur}) )
@@ -2194,9 +2208,9 @@ _VBoxManage() {
;; ;;
--uart-mode[1-2]) --uart-mode[1-2])
COMPREPLY=( $(compgen -W "disconnected serverpipe COMPREPLY=( $(compgen -W "disconnected server
clientpipe tcpserverport tcpclienthostname:port client tcpserver tcpclient
filefilename device-name" -- ${cur}) ) file device-name" -- ${cur}) )
;; ;;
--uart-type[1-2]) --uart-type[1-2])
@@ -2377,10 +2391,10 @@ _VBoxManage() {
[[ ${#COMPREPLY[@]} = 1 && "${COMPREPLY[0]}" != *".vbox" ]] && \ [[ ${#COMPREPLY[@]} = 1 && "${COMPREPLY[0]}" != *".vbox" ]] && \
COMPREPLY[0]="${COMPREPLY[0]}/" COMPREPLY[0]="${COMPREPLY[0]}/"
else else
if [[ $prev == "--passwordfile" ]]; then if [[ $prev == "--password" ]]; then
COMPREPLY=( $(compgen -f -- ${cur}) ) COMPREPLY=( $(compgen -f -- ${cur}) )
else else
local items=( --passwordfile ) local items=( --password )
_get_excluded_items "${items[@]}" _get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) ) COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
fi fi
@@ -2495,12 +2509,12 @@ _VBoxManage() {
_vms_comp vms _vms_comp vms
else else
local items=( --details --machinereadable --log --password-id local items=( --details --machinereadable --log --password-id
--password --password-idid --passwordfile ) --password )
_get_excluded_items "${items[@]}" _get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) ) COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
case "${prev}" in case "${prev}" in
--log|--passwordfile) --log|--password)
COMPREPLY=( $(compgen -f -- ${cur}) ) COMPREPLY=( $(compgen -f -- ${cur}) )
;; ;;
esac esac
@@ -2601,10 +2615,10 @@ _VBoxManage() {
_vms_comp vms 1 _vms_comp vms 1
elif [[ "${prev}" == "--type" ]]; then elif [[ "${prev}" == "--type" ]]; then
COMPREPLY=( $(compgen -W "gui sdl headless separate" -- ${cur}) ) COMPREPLY=( $(compgen -W "gui sdl headless separate" -- ${cur}) )
elif [[ "${prev}" == "--passwordfile" ]]; then elif [[ "${prev}" == "--password" ]]; then
COMPREPLY=( $(compgen -f -- ${cur}) ) COMPREPLY=( $(compgen -f -- ${cur}) )
else else
items=( --type --putenv --passwordfile --password-id ) items=( --type --putenv --password --password-id )
_get_excluded_items "${items[@]}" _get_excluded_items "${items[@]}"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) ) COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
fi fi
@@ -2849,4 +2863,9 @@ _VBoxManage() {
complete -o default -F _VBoxManage VBoxManage complete -o default -F _VBoxManage VBoxManage
complete -o default -F _VBoxManage vboxmanage complete -o default -F _VBoxManage vboxmanage
if [[ "${BASH_SOURCE[0]}" != 'VBoxManage' &&
"${BASH_SOURCE[0]}" != 'vboxmanage' ]]; then
complete -o default -F _VBoxManage $(basename "${BASH_SOURCE[0]}")
fi
# vim: set ft=sh tw=80 sw=4 et : # vim: set ft=sh tw=80 sw=4 et :