5 Commits
6.1.0 ... 6.1.6

Author SHA1 Message Date
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
2 changed files with 57 additions and 53 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
6.1.0, and should contain all commands and their options.
6.1.6, and should contain all commands and their options.
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,11 +4,15 @@
# 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: 6.1.0
# Version: 6.1.6
_VBoxManage() {
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
# 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
@@ -65,10 +69,10 @@ _VBoxManage() {
hdds=$(VBoxManage list hdds | \
grep -A 1 'normal (base)' | \
grep "Location:" | \
sed 's/Location:\s\+//' | \
sed 's/\s/\\ /g' | \
$VBMC_SED 's/Location:\s\+//' | \
$VBMC_SED 's/\s/\\ /g' | \
tr '\n' '|' | \
sed 's/|$//')
$VBMC_SED 's/|$//')
IFS='|' read -ra hdds <<< "$hdds"
for item in "${hdds[@]}"
@@ -83,10 +87,10 @@ _VBoxManage() {
floppies=$(VBoxManage list floppies | \
grep "Location:" | \
sed 's/Location:\s\+//' | \
sed 's/\s/\\ /g' | \
$VBMC_SED 's/Location:\s\+//' | \
$VBMC_SED 's/\s/\\ /g' | \
tr '\n' '|' | \
sed 's/|$//')
$VBMC_SED 's/|$//')
IFS='|' read -ra floppies <<< "$floppies"
for item in "${floppies[@]}"
@@ -101,10 +105,10 @@ _VBoxManage() {
dvds=$(VBoxManage list dvds | \
grep "Location:" | \
sed 's/Location:\s\+//' | \
sed 's/\s/\\ /g' | \
$VBMC_SED 's/Location:\s\+//' | \
$VBMC_SED 's/\s/\\ /g' | \
tr '\n' '|' | \
sed 's/|$//')
$VBMC_SED 's/|$//')
IFS='|' read -ra dvds <<< "$dvds"
for item in "${dvds[@]}"
@@ -130,16 +134,16 @@ _VBoxManage() {
running_vms=$(VBoxManage list runningvms | \
awk -F ' {' '{ print $1 }' | \
tr '\n' '|' | \
sed 's/|$//' | \
sed 's/"//g')
$VBMC_SED 's/|$//' | \
$VBMC_SED 's/"//g')
IFS='|' read -ra running_vms <<< "$running_vms"
fi
vms=$(VBoxManage list $command | \
awk -F ' {' '{ print $1 }' | \
tr '\n' '|' | \
sed 's/|$//' | \
sed 's/"//g')
$VBMC_SED 's/|$//' | \
$VBMC_SED 's/"//g')
IFS='|' read -ra vms <<< "$vms"
for item in "${vms[@]}"
do
@@ -162,10 +166,10 @@ _VBoxManage() {
vms=$(VBoxManage list vms -l | \
egrep '^Name|State' | \
egrep -B1 'State:\s+saved' | \
grep Name |sed 's/Name:\s\+//' | \
grep Name |$VBMC_SED 's/Name:\s\+//' | \
tr '\n' '|' | \
sed 's/|$//' | \
sed 's/"//g')
$VBMC_SED 's/|$//' | \
$VBMC_SED 's/"//g')
IFS='|' read -ra vms <<< "$vms"
for item in "${vms[@]}"
do
@@ -179,9 +183,9 @@ _VBoxManage() {
list=$(VBoxManage list groups | \
tr '\n' '|' | \
sed 's/|$//' | \
sed 's/\s/\\ /g'| \
sed 's/"//g')
$VBMC_SED 's/|$//' | \
$VBMC_SED 's/\s/\\ /g'| \
$VBMC_SED 's/"//g')
IFS='|' read -ra list <<< "$list"
for item in "${list[@]}"
@@ -196,9 +200,9 @@ _VBoxManage() {
list=$(VBoxManage list ostypes | \
egrep ^ID: | \
sed 's/ID:\s\+//' | \
$VBMC_SED 's/ID:\s\+//' | \
tr '\n' '|' | \
sed 's/|$//')
$VBMC_SED 's/|$//')
IFS='|' read -ra list <<< "$list"
for item in "${list[@]}"
@@ -213,10 +217,10 @@ _VBoxManage() {
list=$(VBoxManage list dhcpservers | \
grep NetworkName: | \
sed 's/NetworkName:\s\+//' | \
sed 's/\s/\\ /g'| \
$VBMC_SED 's/NetworkName:\s\+//' | \
$VBMC_SED 's/\s/\\ /g'| \
tr '\n' '|' | \
sed 's/|$//')
$VBMC_SED 's/|$//')
IFS='|' read -ra list <<< "$list"
for item in "${list[@]}"
@@ -231,10 +235,10 @@ _VBoxManage() {
list=$(VBoxManage list hostonlyifs | \
egrep ^Name: | \
sed 's/Name:\s\+//' | \
sed 's/\s/\\ /g'| \
$VBMC_SED 's/Name:\s\+//' | \
$VBMC_SED 's/\s/\\ /g'| \
tr '\n' '|' | \
sed 's/|$//')
$VBMC_SED 's/|$//')
IFS='|' read -ra list <<< "$list"
for item in "${list[@]}"
@@ -253,8 +257,8 @@ _VBoxManage() {
awk -F ',' '{print $1}' | \
awk -F '=' '{print $2}' | \
tr '\n' '|' | \
sed 's/|$//' | \
sed 's/\s/\\ /g')
$VBMC_SED 's/|$//' | \
$VBMC_SED 's/\s/\\ /g')
IFS='|' read -ra rules <<< "$rules"
for item in "${rules[@]}"
@@ -295,7 +299,7 @@ _VBoxManage() {
devs=$(VBoxManage controlvm "${name//\\/}" \
webcam list | \
tr '\n' ' ' | \
sed 's/|s$//')
$VBMC_SED 's/|s$//')
read -ra devs <<< "$devs"
for item in "${devs[@]}"
@@ -312,7 +316,7 @@ _VBoxManage() {
devs=$(VBoxManage list webcams | \
grep dev | \
tr '\n' ' ' | \
sed 's/|s$//')
$VBMC_SED 's/|s$//')
read -ra devs <<< "$devs"
for item in "${devs[@]}"
@@ -323,7 +327,7 @@ _VBoxManage() {
_list_comp() {
local list
list=$(VBoxManage list | sed -e '1,2d' \
list=$(VBoxManage list | $VBMC_SED -e '1,2d' \
-e 's/VBoxManage list //' \
-e 's/[\[\]\|]/ /g' \
-e 's/|/ /g'|xargs echo)
@@ -338,10 +342,10 @@ _VBoxManage() {
folders=$(VBoxManage showvminfo ${vm} --machinereadable | \
grep SharedFolderName | \
awk -F= '{print $2}' | \
sed 's/\s/\\ /g'| \
$VBMC_SED 's/\s/\\ /g'| \
tr '\n' '|' | \
sed 's/|$//' | \
sed 's/"//g')
$VBMC_SED 's/|$//' | \
$VBMC_SED 's/"//g')
IFS='|' read -ra folders <<< "$folders"
for item in "${folders[@]}"
@@ -356,10 +360,10 @@ _VBoxManage() {
list=$(VBoxManage list natnets | \
grep NetworkName: | \
sed 's/NetworkName:\s\+//' | \
sed 's/\s/\\ /g'| \
$VBMC_SED 's/NetworkName:\s\+//' | \
$VBMC_SED 's/\s/\\ /g'| \
tr '\n' '|' | \
sed 's/|$//')
$VBMC_SED 's/|$//')
IFS='|' read -ra list <<< "$list"
for item in "${list[@]}"
@@ -374,10 +378,10 @@ _VBoxManage() {
list=$(VBoxManage list bridgedifs | \
egrep ^Name: | \
sed 's/Name:\s\+//' | \
sed 's/\s/\\ /g'| \
$VBMC_SED 's/Name:\s\+//' | \
$VBMC_SED 's/\s/\\ /g'| \
tr '\n' '|' | \
sed 's/|$//')
$VBMC_SED 's/|$//')
IFS='|' read -ra list <<< "$list"
for item in "${list[@]}"
@@ -392,10 +396,10 @@ _VBoxManage() {
list=$(VBoxManage list intnets| \
egrep ^Name: | \
sed 's/Name:\s\+//' | \
sed 's/\s/\\ /g'| \
$VBMC_SED 's/Name:\s\+//' | \
$VBMC_SED 's/\s/\\ /g'| \
tr '\n' '|' | \
sed 's/|$//')
$VBMC_SED 's/|$//')
IFS='|' read -ra list <<< "$list"
for item in "${list[@]}"
@@ -438,10 +442,10 @@ _VBoxManage() {
providers=$(VBoxManage list cloudproviders | \
grep "Short Name:" | \
sed 's/Short Name:\s\+//' | \
sed 's/\s/\\ /g' | \
$VBMC_SED 's/Short Name:\s\+//' | \
$VBMC_SED 's/\s/\\ /g' | \
tr '\n' '|' | \
sed 's/|$//')
$VBMC_SED 's/|$//')
IFS='|' read -ra providers <<< "$providers"
for item in "${providers[@]}"
@@ -456,10 +460,10 @@ _VBoxManage() {
profiles=$(VBoxManage list cloudprofiles | \
grep "Name:" | \
sed 's/Name:\s\+//' | \
sed 's/\s/\\ /g' | \
$VBMC_SED 's/Name:\s\+//' | \
$VBMC_SED 's/\s/\\ /g' | \
tr '\n' '|' | \
sed 's/|$//')
$VBMC_SED 's/|$//')
IFS='|' read -ra profiles <<< "$profiles"
for item in "${profiles[@]}"
@@ -1277,7 +1281,7 @@ _VBoxManage() {
if [[ " ${items[@]} " == *" $subcommand "* ]]; then
case "${subcommand}" in
install)
_get_excluded_items "--replace"
_get_excluded_items "--replace --accept-license"
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
;;
uninstall)