X-Git-Url: http://id.pley.net/dotfiles.git/blobdiff_plain/4876f76a161e380a4fbf6ce61ef69f0c3a7cd418..2b82952cde87591df9919ee002e04584657e4e5d:/.aliases?ds=inline diff --git a/.aliases b/.aliases index 163f842..12b6b6d 100755 --- a/.aliases +++ b/.aliases @@ -64,3 +64,35 @@ function ssh-learn() { ssh-keyscan -t rsa $1 >> ~/.ssh/known_hosts } +function _ssh_complete() { + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + opts=$( grep -o '^[^, ]\+' ~/.ssh/known_hosts ) + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 +} +complete -F _ssh_complete ssh + +function _ssh_screen () { + DISCONNECT="" + RECONNECT="-R" + HOST=$1 + while [ "$2" != "" ]; do + case $2 in + -d | --disconnect ) + DISCONNECT="-D" + ;; + * ) + echo "Usage: $HOST [-d | --discconnect]" + return 1 + ;; + esac + shift + done + + ssh -t $HOST screen $DISCONNECT $RECONNECT +} + +for host in $( grep '^Host[ ][^*]' ~/.ssh/config | cut -c 6- ); do + alias "$host"="_ssh_screen $host $@" +done