mirror of
https://github.com/gryf/vboxmanage-bash-completion.git
synced 2025-12-19 04:20:25 +01:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c051a4ed9d | |||
|
|
593ec245e5 | ||
| e681abb354 | |||
| cd90fc60bd | |||
| 28553da42d | |||
| 3efab392c1 | |||
| b0352554bb | |||
|
|
95088850b6 | ||
| 3404afa441 | |||
| ab6d9f7cd9 | |||
| 3bb795a1e3 |
@@ -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.8, and should contain all commands and their options.
|
7.0.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:
|
||||||
@@ -42,6 +42,7 @@ be:
|
|||||||
* ~/bash-completion.d/
|
* ~/bash-completion.d/
|
||||||
* /usr/local/etc/bash-completion.d/
|
* /usr/local/etc/bash-completion.d/
|
||||||
* /etc/bash_completion.d/
|
* /etc/bash_completion.d/
|
||||||
|
* ~/.local/share/bash-completion
|
||||||
* etc.
|
* etc.
|
||||||
|
|
||||||
It's also okay to copy it into some directory, and place proper line in
|
It's also okay to copy it into some directory, and place proper line in
|
||||||
|
|||||||
75
VBoxManage
75
VBoxManage
@@ -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.8
|
# Version: 7.0.22
|
||||||
|
|
||||||
|
|
||||||
_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,20 +826,20 @@ _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 nic1 nic2 nic3 nic4
|
natpf4 natpf5 natpf6 natpf7 natpf8 natpf9 nic1 nic2 nic3 nic4
|
||||||
nic5 nic6 nic7 nic8 nicpromisc1 nicpromisc2 nicpromisc3
|
nic5 nic6 nic7 nic8 nicpromisc1 nicpromisc2 nicpromisc3
|
||||||
nicpromisc4 nicpromisc5 nicpromisc6 nicpromisc7 nicpromisc8
|
nicpromisc4 nicpromisc5 nicpromisc6 nicpromisc7 nicpromisc8
|
||||||
nicproperty1 nicproperty2 nicproperty3 nicproperty4 nicproperty5
|
nicproperty1 nicproperty2 nicproperty3 nicproperty4 nicproperty5
|
||||||
nicproperty6 nicproperty7 nicproperty8 nictrace1 nictrace2
|
nicproperty6 nicproperty7 nicproperty8 nictrace1 nictrace2
|
||||||
nictrace3 nictrace4 nictrace5 nictrace6 nictrace7 nictrace8
|
nictrace3 nictrace4 nictrace5 nictrace6 nictrace7 nictrace8
|
||||||
nictracefile1 nictracefile2 nictracefile3 nictracefile4
|
nictracefile1 nictracefile2 nictracefile3 nictracefile4
|
||||||
nictracefile5 nictracefile6 nictracefile7 nictracefile8 pause
|
nictracefile5 nictracefile6 nictracefile7 nictracefile8 pause
|
||||||
plugcpu poweroff reboot recording removeallencpasswords
|
plugcpu poweroff reboot recording removeallencpasswords
|
||||||
removeencpassword reset resume savestate screenshotpng
|
removeencpassword reset resume savestate screenshotpng
|
||||||
setcredentials setlinkstate1 setlinkstate2 setlinkstate3
|
setcredentials setlinkstate1 setlinkstate2 setlinkstate3
|
||||||
setlinkstate4 setlinkstate5 setlinkstate6 setlinkstate7
|
setlinkstate4 setlinkstate5 setlinkstate6 setlinkstate7
|
||||||
setlinkstate8 setscreenlayout setvideomodehint shutdown teleport
|
setlinkstate8 setscreenlayout setvideomodehint shutdown teleport
|
||||||
unplugcpu usbattach usbdetach vm-process-priority vrde vrdeport
|
unplugcpu usbattach usbdetach vm-process-priority vrde vrdeport
|
||||||
vrdeproperty vrdevideochannelquality webcam )
|
vrdeproperty vrdevideochannelquality webcam )
|
||||||
|
|
||||||
_find_item_name 2
|
_find_item_name 2
|
||||||
@@ -930,7 +937,7 @@ _VBoxManage() {
|
|||||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||||
;;
|
;;
|
||||||
changeuartmode[1-2])
|
changeuartmode[1-2])
|
||||||
tmp=(disconnected server client tcpserver tcpclient
|
tmp=(disconnected server client tcpserver tcpclient
|
||||||
file device-name)
|
file device-name)
|
||||||
_get_excluded_items "${tmp[@]}"
|
_get_excluded_items "${tmp[@]}"
|
||||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||||
@@ -1038,7 +1045,7 @@ _VBoxManage() {
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
createvm)
|
createvm)
|
||||||
items=( --basefolder --cipher --default --group --name --ostype
|
items=( --basefolder --cipher --default --groups --name --ostype
|
||||||
--password-id --password --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}) )
|
||||||
@@ -1047,7 +1054,7 @@ _VBoxManage() {
|
|||||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||||
|
|
||||||
case "${prev}" in
|
case "${prev}" in
|
||||||
--group)
|
--groups)
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
_group_comp
|
_group_comp
|
||||||
;;
|
;;
|
||||||
@@ -1425,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 -- )
|
||||||
@@ -1445,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 "* ]] &&
|
||||||
@@ -2855,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 :
|
||||||
|
|||||||
Reference in New Issue
Block a user