/bash_completion.d/qemu

http://github.com/brinkman83/bashrc · #! · 132 lines · 126 code · 6 blank · 0 comment · 0 complexity · 9262fe9015aa06919a73879060e546d5 MD5 · raw file

  1. # bash completion for qemu
  2. have qemu &&
  3. _qemu()
  4. {
  5. local cur prev
  6. COMPREPLY=()
  7. cur=`_get_cword`
  8. prev=${COMP_WORDS[COMP_CWORD-1]}
  9. case $prev in
  10. -@(fd[ab]|hd[abcd]|cdrom|option-rom|kernel|initrd|bootp|pidfile|loadvm|mtdblock|sd|pflash|bios))
  11. _filedir
  12. return 0
  13. ;;
  14. -@(tftp|smb|L|chroot))
  15. _filedir -d
  16. return 0
  17. ;;
  18. -boot)
  19. COMPREPLY=( $( compgen -W 'a c d n' -- "$cur" ) )
  20. return 0
  21. ;;
  22. -k)
  23. COMPREPLY=( $( compgen -W 'ar de-ch es fo fr-ca hu ja \
  24. mk no pt-br sv da en-gb et fr fr-ch is lt nl pl\
  25. ru th de en-us fi fr-be hr it lv nl-be pt sl tr' -- "$cur" ) )
  26. return 0
  27. ;;
  28. -soundhw)
  29. COMPREPLY=( $( compgen -W "$( qemu -soundhw ? | awk \
  30. '/^[[:lower:]]/ {print $1}' ) all" -- "$cur" ) )
  31. return 0
  32. ;;
  33. -M)
  34. COMPREPLY=( $( compgen -W "$( qemu -M ? | awk \
  35. '/^[[:lower:]]/ {print $1}' )" -- "$cur" ) )
  36. return 0
  37. ;;
  38. -cpu)
  39. COMPREPLY=( $( compgen -W "$( qemu -cpu ? | awk \
  40. '{print $2}' )" -- "$cur" ) )
  41. return 0
  42. ;;
  43. -usbdevice)
  44. COMPREPLY=( $( compgen -W 'mouse tablet disk: host: \
  45. serial: braille net' -- "$cur" ) )
  46. return 0
  47. ;;
  48. -net)
  49. COMPREPLY=( $( compgen -W 'nic user tap socket vde none dump' \
  50. -- "$cur" ) )
  51. return 0
  52. ;;
  53. -@(serial|parallel|monitor))
  54. COMPREPLY=( $( compgen -W 'vc pty none null /dev/ \
  55. file: stdio pipe: COM udp: tcp: telnet: unix: \
  56. mon: braille' -- "$cur" ) )
  57. return 0
  58. ;;
  59. -redir)
  60. COMPREPLY=( $( compgen -S":" -W 'tcp udp' -- "$cur" ) )
  61. return 0
  62. ;;
  63. -bt)
  64. COMPREPLY=( $( compgen -W 'hci vhci device' -- "$cur" ) )
  65. return 0
  66. ;;
  67. -vga)
  68. COMPREPLY=( $( compgen -W 'cirrus std vmware xenfb none' \
  69. -- "$cur" ) )
  70. return 0
  71. ;;
  72. -drive)
  73. COMPREPLY=( $( compgen -S"=" -W 'file if bus unit index media \
  74. cyls snapshot cache format serial addr' -- "$cur" ) )
  75. return 0
  76. ;;
  77. -ballon)
  78. COMPREPLY=( $( compgen -W 'none virtio' -- "$cur" ) )
  79. return 0
  80. ;;
  81. -smbios)
  82. COMPREPLY=( $( compgen -W 'file type' -- "$cur" ) )
  83. return 0
  84. ;;
  85. -watchdog)
  86. COMPREPLY=( $( compgen -W "$( qemu -watchdog ? 2>&1 | \
  87. awk '{print $1}' )" -- "$cur" ) )
  88. return 0
  89. ;;
  90. -watchdog-action)
  91. COMPREPLY=( $( compgen -W 'reset shutdown poweroff pause debug \
  92. none' -- "$cur" ) )
  93. return 0
  94. ;;
  95. -runas)
  96. COMPREPLY=( $( compgen -u -- "$cur" ) )
  97. return 0
  98. ;;
  99. esac
  100. if [[ "$cur" == -* ]]; then
  101. COMPREPLY=( $( compgen -W '-M -fda -fdb -hda -hdb -hdc -hdd \
  102. -cdrom -boot -snapshot -no-fd-bootchk -m -smp -nographic -vnc \
  103. -k -audio-help -soundhw -localtime -full-screen -pidfile \
  104. -daemonize -win2k-hack -option-rom -usb -usbdevice -net -tftp \
  105. -smb -redir -kernel -append -initrd -serial -parallel -monitor \
  106. -s -p -S -d -hdachs -L -std-vga -no-acpi -no-reboot -loadvm \
  107. -semihosting -cpu -bt -vga -drive -startdate -name -curses \
  108. -no-frame -no-quit -bootp -echr -no-shutdown -icount -g \
  109. -prom-env -h -help -version -numa -mtdblock -sd -pflash \
  110. -device -uuid -alt-grab -sdl -portrait -rtc-td-hack -no-hpet \
  111. -balloon -acpitable -smbios -singlestep -gdb -hdachs -bios \
  112. -kernel-kqemu -enable-kqemu -enable-kvm -clock -watchdog \
  113. -watchdog-action -virtioconsole -show-cursor -tb-size -incoming \
  114. -chroot -runas' -- "$cur" ) )
  115. else
  116. _filedir
  117. fi
  118. } &&
  119. complete -F _qemu $filenames qemu
  120. # Local variables:
  121. # mode: shell-script
  122. # sh-basic-offset: 4
  123. # sh-indent-comment: t
  124. # indent-tabs-mode: nil
  125. # End:
  126. # ex: ts=4 sw=4 et filetype=sh