mirror of
https://github.com/gryf/vboxmanage-bash-completion.git
synced 2025-12-17 19:40:17 +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.
|
VBoxManage bash completion script.
|
||||||
|
|
||||||
This version of the completion was initially based on Sebastian T. Hafner
|
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.
|
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
|
||||||
4.3.18, and supports dcommands:
|
4.3.18, and supports commands:
|
||||||
|
|
||||||
- adoptstate
|
- adoptstate
|
||||||
- bandwidthctl
|
- bandwidthctl
|
||||||
|
- clonehd
|
||||||
|
- clonevm
|
||||||
|
- controlvm
|
||||||
|
- list
|
||||||
|
- showhdinfo
|
||||||
|
- showvminfo
|
||||||
|
|||||||
67
VBoxManage
67
VBoxManage
@@ -27,7 +27,7 @@
|
|||||||
# [ ] guestproperty
|
# [ ] guestproperty
|
||||||
# [ ] hostonlyif
|
# [ ] hostonlyif
|
||||||
# [ ] import
|
# [ ] import
|
||||||
# [ ] list
|
# [x] list
|
||||||
# [ ] metrics
|
# [ ] metrics
|
||||||
# [ ] modifyhd
|
# [ ] modifyhd
|
||||||
# [ ] modifyvm - a LOT options missing
|
# [ ] modifyvm - a LOT options missing
|
||||||
@@ -36,8 +36,8 @@
|
|||||||
# [ ] setextradata
|
# [ ] setextradata
|
||||||
# [ ] setproperty
|
# [ ] setproperty
|
||||||
# [ ] sharedfolder
|
# [ ] sharedfolder
|
||||||
# [ ] showhdinfo
|
# [x] showhdinfo
|
||||||
# [ ] showvminfo
|
# [x] showvminfo
|
||||||
# [ ] snapshot
|
# [ ] snapshot
|
||||||
# [ ] startvm
|
# [ ] startvm
|
||||||
# [ ] storageattach - no all options yet
|
# [ ] storageattach - no all options yet
|
||||||
@@ -253,6 +253,36 @@ _VBoxManage() {
|
|||||||
done
|
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
|
COMP_WORDBREAKS=${COMP_WORDBREAKS//|/} # remove pipe from comp word breaks
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
|
|
||||||
@@ -492,6 +522,8 @@ _VBoxManage() {
|
|||||||
list" -- ${cur}) )
|
list" -- ${cur}) )
|
||||||
[[ ${prev} == "detach" ]] && \
|
[[ ${prev} == "detach" ]] && \
|
||||||
_webcam_comp ${cur}
|
_webcam_comp ${cur}
|
||||||
|
[[ ${prev} == "attach" ]] && \
|
||||||
|
_webcam_avail_comp ${cur}
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
@@ -527,6 +559,18 @@ _VBoxManage() {
|
|||||||
import)
|
import)
|
||||||
;;
|
;;
|
||||||
list)
|
list)
|
||||||
|
if [[ ${prev} == ${cmd} ]]; then
|
||||||
|
_list_comp ${cur}
|
||||||
|
else
|
||||||
|
case "${prev}" in
|
||||||
|
--long|-l)
|
||||||
|
COMPREPLY=()
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
COMPREPLY=( $(compgen -W "-l --long" -- ${cur}) )
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
metrics)
|
metrics)
|
||||||
;;
|
;;
|
||||||
@@ -545,8 +589,25 @@ _VBoxManage() {
|
|||||||
sharedfolder)
|
sharedfolder)
|
||||||
;;
|
;;
|
||||||
showhdinfo)
|
showhdinfo)
|
||||||
|
_hdd_comp ${cur}
|
||||||
;;
|
;;
|
||||||
showvminfo)
|
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)
|
snapshot)
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user