mirror of
https://github.com/gryf/vboxmanage-bash-completion.git
synced 2025-12-17 11:30:23 +01:00
Added support for list, showvminfo and showhdinfo commands
This commit is contained in:
10
README
10
README
@@ -1,11 +1,17 @@
|
||||
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 revrite it almost from
|
||||
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.18, and supports dcommands:
|
||||
4.3.18, and supports commands:
|
||||
|
||||
- adoptstate
|
||||
- bandwidthctl
|
||||
- clonehd
|
||||
- clonevm
|
||||
- controlvm
|
||||
- list
|
||||
- showhdinfo
|
||||
- showvminfo
|
||||
|
||||
67
VBoxManage
67
VBoxManage
@@ -27,7 +27,7 @@
|
||||
# [ ] guestproperty
|
||||
# [ ] hostonlyif
|
||||
# [ ] import
|
||||
# [ ] list
|
||||
# [x] list
|
||||
# [ ] metrics
|
||||
# [ ] modifyhd
|
||||
# [ ] modifyvm - a LOT options missing
|
||||
@@ -36,8 +36,8 @@
|
||||
# [ ] setextradata
|
||||
# [ ] setproperty
|
||||
# [ ] sharedfolder
|
||||
# [ ] showhdinfo
|
||||
# [ ] showvminfo
|
||||
# [x] showhdinfo
|
||||
# [x] showvminfo
|
||||
# [ ] snapshot
|
||||
# [ ] startvm
|
||||
# [ ] storageattach - no all options yet
|
||||
@@ -253,6 +253,36 @@ _VBoxManage() {
|
||||
done
|
||||
}
|
||||
|
||||
_webcam_avail_comp() {
|
||||
local devs cur=$1
|
||||
local item
|
||||
|
||||
_find_item_name 2
|
||||
devs=$(VBoxManage list webcams | \
|
||||
grep dev | \
|
||||
tr '\n' ' ' | \
|
||||
sed 's/|s$//')
|
||||
read -ra devs <<< "$devs"
|
||||
|
||||
for item in "${devs[@]}"
|
||||
do
|
||||
[[ ${item^^} == ${cur^^}* ]] && COMPREPLY+=("$item")
|
||||
done
|
||||
}
|
||||
|
||||
_list_comp() {
|
||||
local list
|
||||
list=$(VBoxManage list | \
|
||||
grep '|' | \
|
||||
sed 's/\[.*\]//g'| \
|
||||
sed 's/VBoxManage list//' | \
|
||||
tr "\\n" " " | \
|
||||
sed 's/$/\n/' | \
|
||||
sed 's/\s\+//g' | \
|
||||
sed 's/|/ /g')
|
||||
COMPREPLY=( $(compgen -W "$list" -- ${cur}) )
|
||||
}
|
||||
|
||||
COMP_WORDBREAKS=${COMP_WORDBREAKS//|/} # remove pipe from comp word breaks
|
||||
COMPREPLY=()
|
||||
|
||||
@@ -492,6 +522,8 @@ _VBoxManage() {
|
||||
list" -- ${cur}) )
|
||||
[[ ${prev} == "detach" ]] && \
|
||||
_webcam_comp ${cur}
|
||||
[[ ${prev} == "attach" ]] && \
|
||||
_webcam_avail_comp ${cur}
|
||||
;;
|
||||
esac
|
||||
else
|
||||
@@ -527,6 +559,18 @@ _VBoxManage() {
|
||||
import)
|
||||
;;
|
||||
list)
|
||||
if [[ ${prev} == ${cmd} ]]; then
|
||||
_list_comp ${cur}
|
||||
else
|
||||
case "${prev}" in
|
||||
--long|-l)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=( $(compgen -W "-l --long" -- ${cur}) )
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
metrics)
|
||||
;;
|
||||
@@ -545,8 +589,25 @@ _VBoxManage() {
|
||||
sharedfolder)
|
||||
;;
|
||||
showhdinfo)
|
||||
_hdd_comp ${cur}
|
||||
;;
|
||||
showvminfo)
|
||||
if [[ ${prev} == ${cmd} ]]; then
|
||||
_vms_comp vms ${cur}
|
||||
else
|
||||
if [[ " ${COMP_WORDS[@]} " == *" --log "* ]]; then
|
||||
COMPREPLY=()
|
||||
elif [[ " ${COMP_WORDS[@]} " == *" --details "* ||
|
||||
" ${COMP_WORDS[@]} " == *" --machinereadable "* ]]; then
|
||||
local items=(--details --machinereadable)
|
||||
_get_excluded_items "${items[@]}"
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
else
|
||||
local items=(--details --machinereadable --log)
|
||||
_get_excluded_items "${items[@]}"
|
||||
COMPREPLY=( $(compgen -W "$result" -- ${cur}) )
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
snapshot)
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user