mssh.bash-completion 656 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. # bash completion for mssh
  2. # Written by Héctor García <[email protected]>
  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