From: Iain Patterson Date: Tue, 8 Apr 2014 13:05:40 +0000 (+0100) Subject: Better SSH completion. X-Git-Url: http://git.iain.cx/?a=commitdiff_plain;h=88bb919af5a85d1d7f791408058f9eee96140907;p=profile.git Better SSH completion. Complete based on known hosts and DSH groups as well as explicit entries in .ssh/hosts. --- diff --git a/.profile.d/completion.bashrc b/.profile.d/completion.bashrc index 8ff324d..782cb69 100644 --- a/.profile.d/completion.bashrc +++ b/.profile.d/completion.bashrc @@ -38,6 +38,27 @@ function _known_hosts() { return 0 } +# Host completion from dsh groups. +function _dshgroup() { + cur=${COMP_WORDS[COMP_CWORD]} + + HOSTS=$(grep -rh '^[A-Za-z0-9]' ~/.dsh/group) + + COMPREPLY=($(compgen -W "$HOSTS" -- "$cur")) + return 0 +} + +function _omnissh() { + cur=${COMP_WORDS[COMP_CWORD]} + + HOSTS="$(grep -rh '^[A-Za-z0-9]' ~/.dsh/group) +$(sed 's/[ ].*//;s/,/\n/' ~/.ssh/known_hosts) +$(find $COMPLETION_DIR_SSH -type f -perm -100 2>/dev/null | sed 's@.*/@@')" + + COMPREPLY=($(compgen -W "$HOSTS" -- "$cur")) + return 0 +} + # Process completion for kill, strace etc. function _pid() { cur=${COMP_WORDS[COMP_CWORD]} @@ -114,9 +135,9 @@ function _global() { return 0 } -complete -F _ssh rollout -complete -F _ssh ssh -complete -F _ssh sshterm +complete -F _omnissh rollout +complete -F _omnissh ssh +complete -F _omnissh sshterm complete -F _ping telnet complete -F _telnet telnetterm complete -F _rdp rdesktop @@ -129,6 +150,7 @@ complete -F _pid kill complete -F _pid strace complete -F _known_hosts kill_known_host complete -F _known_hosts knh +complete -F _omnissh knh complete -F _modprobe modprobe complete -F _rmmod rmmod complete -F _global global