Merge pull request #13 from taradiddles/master

add bash autocompletion script
This commit is contained in:
awokd 2018-04-04 09:29:14 +00:00 committed by GitHub
commit 4608ea6ac4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,52 @@
# qvm-* commands bash auto completion
# copy this file to /etc/bash_completion.d/qvm.sh
# make sure 'bash-completion' is installed (sudo qubes-dom0-update bash-completion)
# credit: https://www.mail-archive.com/qubes-users@googlegroups.com/msg20088.html
_qvm()
{
local cur vms
local state=${1}
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
case ${state} in
running|halted|paused)
vms=$(qvm-ls --raw-data | grep -i "|${state}|" | cut -f1 -d"|")
;;
"")
vms=$(qvm-ls --raw-list)
;;
*) vms=""
esac
COMPREPLY=( $(compgen -W "${vms}" ${cur}) )
return 0
}
_qvmall() { _qvm ""; }
_qvmrunning() { _qvm "running"; }
_qvmhalted() { _qvm "halted"; }
_qvmpaused() { _qvm "paused"; }
complete -F _qvmall qvm-appmenus
complete -F _qvmall qvm-backup
complete -F _qvmall qvm-backup-restore
complete -F _qvmall qvm-check
complete -F _qvmall qvm-clone
complete -F _qvmall qvm-copy-to-vm
complete -F _qvmall qvm-features
complete -F _qvmall qvm-firewall
complete -F _qvmall qvm-move-to-vm
complete -F _qvmall qvm-prefs
complete -F _qvmall qvm-remove
complete -F _qvmall qvm-run
complete -F _qvmall qvm-service
complete -F _qvmall qvm-start-gui
complete -F _qvmall qvm-tags
complete -F _qvmall qvm-usb
complete -F _qvmhalted qvm-start
complete -F _qvmpaused qvm-unpause
complete -F _qvmrunning qvm-kill
complete -F _qvmrunning qvm-pause
complete -F _qvmrunning qvm-shutdown