mssh.bash-completion 656 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # bash completion for mssh
  2. # Written by Héctor García <hector@debian.org>
  3. _mssh_alias()
  4. {
  5. if [ -f ~/.mssh_clusters ]; then
  6. COMPREPLY=( $( compgen -W '$( command cat ~/.mssh_clusters 2>/dev/null \
  7. | grep -v "^\s*$" | grep -v "^#" | sed -e "s/:.*$//" )' -- $cur ) )
  8. fi
  9. return 0
  10. }
  11. _mssh()
  12. {
  13. local cur=${COMP_WORDS[COMP_CWORD]}
  14. local prev=${COMP_WORDS[COMP_CWORD-1]}
  15. COMPREPLY=()
  16. case "$prev" in
  17. -a)
  18. _mssh_alias
  19. return 0
  20. ;;
  21. esac
  22. # completing -a option
  23. if [[ "$cur" == -* ]]; then
  24. COMPREPLY=( $( compgen -W "-a" -- $cur ) )
  25. return 0
  26. fi
  27. _known_hosts_real "$cur"
  28. }
  29. complete -F _mssh mssh