[virt-tools-list] [PATCH] Bash completion for virt-manager utilities

Abhijeet Kasurde akasurde at redhat.com
Sat Oct 24 16:27:54 UTC 2015


Added bash completion script for virt-xml, virt-install, virt-clone and
virt-convert

Signed-off-by: Abhijeet Kasurde <akasurde at redhat.com>
---
 data/bash.completion/virt-manager.bash | 82 ++++++++++++++++++++++++++++++++++
 setup.py                               |  1 +
 2 files changed, 83 insertions(+)
 create mode 100644 data/bash.completion/virt-manager.bash

diff --git a/data/bash.completion/virt-manager.bash b/data/bash.completion/virt-manager.bash
new file mode 100644
index 0000000..1ebc4ab
--- /dev/null
+++ b/data/bash.completion/virt-manager.bash
@@ -0,0 +1,82 @@
+_virt_install()
+{
+    local cur prev opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    opts="-h --help --version --connect -n --name --memory --vcpus --cpu \
+        --metadata --cdrom -l --location --pxe --import --livecd --boot -x \
+        --extra-args --initrd-inject --os-variant --idmap --disk --network \
+        --graphics --controller --input --serial --parallel --channel -w \
+        --console --hostdev --filesystem --sound --watchdog --video \
+        --smartcard --redirdev --memballoon --tpm --rng --panic \
+        --security --numatune --memtune --blkiotune --memorybacking \
+        --features --clock --pm --events --resource -v --hvm -p --paravirt \
+        --container --virt-type --arch --machine --autostart \
+        --wait --noautoconsole --noreboot --print-xml --dry-run \
+        --check --quiet --debug -q -d"
+
+    if [[ ${cur} == -* ]]; then
+        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+        return 0
+    fi
+}
+
+_virt_clone()
+{
+    local cur prev opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    opts="-h --help --version --connect -o --original --original-xml --auto-clone \
+        -n --name --reflink -f --file --force-copy --nonsparse --preserve-data -m \
+        --mac --replace --print-xml --check -q --quiet -d --debug"
+
+    if [[ ${cur} == -* ]]; then
+        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+        return 0
+    fi
+}
+
+_virt_convert()
+{
+    local cur prev opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    opts="-h --help --version --connect -i --input-format -D --disk-format \
+        --destination --noautoconsole --print-xml --dry-run -q --quiet -d  \
+        --debug"
+
+    if [[ ${cur} == -* ]]; then
+        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+        return 0
+    fi
+}
+
+_virt_xml()
+{
+    local cur prev opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    opts="-h --help --version -c --connect --edit --remove-device --add-device \
+        --build-xml --update --define --print-diff --print-xml --confirm --disk \
+        -w --network --graphics --metadata --memory --vcpus --cpu --security \
+        --numatune --memtune --blkiotune --memorybacking --features --clock \
+        --pm --events --resource --boot --idmap --controller --input --serial \
+        --parallel --channel --console --hostdev --filesystem --sound \
+        --watchdog --video --smartcard --redirdev --memballoon --tpm --rng \
+        --panic -q --quiet -d --debug"
+
+    echo $COMP_CWORD
+    if [[ ${cur} == -* ]]; then
+        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+        return 0
+    fi
+}
+
+complete -F _virt_install virt-install
+complete -F _virt_clone virt-clone
+complete -F _virt_convert virt-convert
+complete -F _virt_xml virt-xml
diff --git a/setup.py b/setup.py
index 72f4d0f..d48d1b5 100755
--- a/setup.py
+++ b/setup.py
@@ -637,6 +637,7 @@ setup(
          glob.glob("virtcli/*.py") + glob.glob("virtcli/cli.cfg")),
         ("share/virt-manager/virtinst", glob.glob("virtinst/*.py")),
         ("share/virt-manager/virtconv", glob.glob("virtconv/*.py")),
+        ("/etc/bash_completion.d", ["data/bash.completion/virt-manager.bash"]),
     ],
 
     cmdclass={
-- 
2.4.3




More information about the virt-tools-list mailing list