mirror of
https://github.com/gryf/vboxmanage-bash-completion.git
synced 2025-12-17 11:30:23 +01:00
Added createvm command
This commit is contained in:
1
README
1
README
@@ -15,6 +15,7 @@ Current version of script was written and tested against VBoxManage in version
|
||||
- controlvm
|
||||
- convertfromraw
|
||||
- createhd
|
||||
- createvm
|
||||
- list
|
||||
- showhdinfo
|
||||
- showvminfo
|
||||
|
||||
46
VBoxManage
46
VBoxManage
@@ -16,7 +16,7 @@
|
||||
# [x] controlvm
|
||||
# [x] convertfromraw
|
||||
# [x] createhd
|
||||
# [ ] createvm
|
||||
# [x] createvm
|
||||
# [ ] debugvm
|
||||
# [ ] dhcpserver
|
||||
# [ ] discardstate
|
||||
@@ -145,6 +145,7 @@ _VBoxManage() {
|
||||
sed 's/|/ /g')
|
||||
COMPREPLY=( $(compgen -W "$list" -- ${cur}) )
|
||||
}
|
||||
|
||||
_group_comp() {
|
||||
local cur=$1
|
||||
local list
|
||||
@@ -163,6 +164,24 @@ _VBoxManage() {
|
||||
done
|
||||
}
|
||||
|
||||
_os_comp() {
|
||||
local cur=$1
|
||||
local list
|
||||
local item
|
||||
|
||||
list=$(VBoxManage list ostypes | \
|
||||
egrep ^ID: | \
|
||||
sed 's/ID:\s\+//' | \
|
||||
tr '\n' '|' | \
|
||||
sed 's/|$//')
|
||||
IFS='|' read -ra list <<< "$list"
|
||||
|
||||
for item in "${list[@]}"
|
||||
do
|
||||
[[ ${item^^} == ${cur^^}* ]] && COMPREPLY+=("$item")
|
||||
done
|
||||
}
|
||||
|
||||
# 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
|
||||
@@ -582,6 +601,31 @@ _VBoxManage() {
|
||||
fi
|
||||
;;
|
||||
createvm)
|
||||
items=(--name --groups --ostype --register --basefolder --uuid)
|
||||
if [[ ${prev} == ${cmd} ]]; then
|
||||
COMPREPLY=( $(compgen -W "${items[*]}" -- ${cur}) )
|
||||
else
|
||||
_get_excluded_items "${items[@]}"
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
|
||||
case "${prev}" in
|
||||
--groups)
|
||||
COMPREPLY=()
|
||||
_group_comp ${cur}
|
||||
;;
|
||||
--ostype)
|
||||
COMPREPLY=()
|
||||
_os_comp ${cur}
|
||||
;;
|
||||
--basefolder)
|
||||
COMPREPLY=( $(compgen -o dirnames -- ${cur}) )
|
||||
;;
|
||||
--variant)
|
||||
COMPREPLY=( $(compgen -W "Standard Fixed Split2G Stream
|
||||
ESX" -- ${cur}) )
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
debugvm)
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user