All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
3 # ssh configuration for zsh
5 # Copyright © 2008 martin f. krafft <madduck@madduck.net>
6 # Released under the terms of the Artistic Licence 2.0
8 # Source repository: git://git.madduck.net/etc/ssh.git
11 # populate hosts completion with SSH's known_hosts
12 if [ -r $HOME/.ssh/known_hosts ]; then
14 _myhosts=$(while read host rest; do
17 ([[:alnum:]]*) echo "$host";;
18 (\[[[:alnum:]]*) echo "${${host#\[}%\]*}";;
20 done < ~/.ssh/known_hosts)
21 #_myhosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*})
22 #zstyle ':completion:*' hosts $_myhosts
27 local cmd sshopts cmdopts
29 sshopts="${*%%--*}"; sshopts="${sshopts%% }"
30 [[ -n "$sshopts" ]] || { ssh; return $? }
31 cmdopts="${*#$sshopts}"; cmdopts="${cmdopts#*-- }"
32 eval ssh $sshopts -t $cmd $cmdopts
35 # need functions instead of aliases for completion
36 rrsh() { _ssh_proxy "sudo -i" "$@" }
39 ttsh() { _ssh_proxy "tmux last" "$@" }
42 rtsh() { _ssh_proxy "tmux new sudo -i" "$@" }
45 declare _SSH_SOCKDIR="${VARDIR}/ssh"
47 if [[ -z "$1" ]]; then
48 rm -vf -- ${_SSH_SOCKDIR}/*(=as-60Y1omN)
53 compdef -e "compset -P ${_SSH_SOCKDIR}/ || PREFIX=${_SSH_SOCKDIR}/; _files -W ${_SSH_SOCKDIR}" kssh
56 local args host dir arg
60 (*:*) host=${arg%%:*}; dir="${arg#*:}";;
61 (*) args="${args:+$args }$arg";;
65 if [[ -z $dir ]]; then
70 ssh -t $args $host "cd '${dir:gs/\'/\'\\\'\'}' && exec \$SHELL --login"