/bash_completion_lib/complete/vncviewer

http://github.com/brinkman83/bashrc · #! · 30 lines · 23 code · 7 blank · 0 comment · 0 complexity · cee50f7e6950486674e2d8bada4009bb MD5 · raw file

  1. # vncviewer(1) completion
  2. comp_include _get_cword _known_hosts
  3. _vncviewer()
  4. {
  5. local cur prev
  6. local -a config
  7. COMPREPLY=()
  8. cur=`_get_cword`
  9. prev=${COMP_WORDS[COMP_CWORD-1]}
  10. case "$prev" in
  11. -via)
  12. _known_hosts -a
  13. ;;
  14. *)
  15. # ssh into the the server, find and ping the broadcast address, then
  16. # sort and show the results.
  17. COMPREPLY=( $( ssh -o 'Batchmode yes' $prev \
  18. "ping -bnc 4 255.255.255.255" 2>/dev/null | \
  19. awk -F ' ' '{print $4}' | \
  20. sort -n | uniq | egrep '[0-9]+\.[0-9]+\.' 2>/dev/null ) )
  21. esac
  22. return 0
  23. } # _vncviewer()