# Bash completion for rtadm _rtadm_ra_hosts_disabled() { awk '/^#DISABLED#/ {print $5}' .ssh/authorized_keys | cut -d- -f3 } _rtadm_ra_hosts_enabled() { awk '/^[^#].* ra-/ {print $5}' .ssh/authorized_keys | cut -d- -f3 } _rtadm_ra_hosts() { awk '/ ra-/ {print $5}' .ssh/authorized_keys | cut -d- -f3 } _rtadm() { local cur commands command hosts COMPREPLY=() cur=`_get_cword` commands='create show enable disable disconnect upload delete' if [[ $COMP_CWORD -eq 1 ]] ; then COMPREPLY=( $( compgen -W "$commands" -- $cur ) ) return 0 fi command=${COMP_WORDS[1]} case "$command" in create) # Fixme: some completion here. : #create [-e] port newname ;; show) : # No parameters here ;; enable) hosts=`_rtadm_ra_hosts_disabled` COMPREPLY=( $( compgen -W "$hosts" -- $cur ) ) ;; disable|disconnect) hosts=`_rtadm_ra_hosts_enabled` COMPREPLY=( $( compgen -W "$hosts" -- $cur ) ) ;; delete|upload) hosts=`_rtadm_ra_hosts` COMPREPLY=( $( compgen -W "$hosts" -- $cur ) ) ;; esac return 0 } complete -F _rtadm rtadm