4 # To enabled agent forwarding support add the following to
7 # zstyle :omz:plugins:ssh-agent agent-forwarding on
9 # To load multiple identies use the identities style, For
12 # zstyle :omz:plugins:ssh-agent id_rsa id_rsa2 id_github
17 # Based on code from Joseph M. Reagle
18 # http://www.cygwin.com/ml/cygwin/2001-06/msg00537.html
20 # Agent forwarding support based on ideas from
21 # Florent Thoumie and Jonas Pfenniger
24 local _plugin__ssh_env
=$HOME/.ssh
/environment
-$HOST
25 local _plugin__forwarding
27 function _plugin__start_agent
()
31 # start ssh-agent and setup environment
32 /usr
/bin
/env
ssh-agent | sed 's/^echo/#echo/' > ${_plugin__ssh_env}
33 chmod 600 ${_plugin__ssh_env}
34 .
${_plugin__ssh_env} > /dev
/null
37 zstyle
-a :omz
:plugins
:ssh-agent identities identities
39 /usr
/bin
/ssh-add $HOME/.ssh
/${^identities}
42 # test if agent-forwarding is enabled
43 zstyle
-b :omz
:plugins
:ssh-agent agent
-forwarding _plugin__forwarding
44 if [[ ${_plugin__forwarding} == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
45 # Add a nifty symlink for screen/tmux if agent forwarding
46 [[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp
/ssh-agent-$USER-screen
48 elif [ -f "${_plugin__ssh_env}" ]; then
49 # Source SSH settings, if applicable
50 .
${_plugin__ssh_env} > /dev
/null
51 ps
-ef | grep ${SSH_AGENT_PID} | grep ssh-agent$
> /dev
/null
|| {
58 # tidy up after ourselves
59 unfunction _plugin__start_agent
60 unset _plugin__forwarding
61 unset _plugin__ssh_env