12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- local _plugin__ssh_env
- local _plugin__forwarding
- function _plugin__start_agent()
- {
- local -a identities
- local lifetime
- zstyle -s :omz:plugins:ssh-agent lifetime lifetime
-
- /usr/bin/env ssh-agent ${lifetime:+-t} ${lifetime} | sed 's/^echo/#echo/' > ${_plugin__ssh_env}
- chmod 600 ${_plugin__ssh_env}
- . ${_plugin__ssh_env} > /dev/null
-
- zstyle -a :omz:plugins:ssh-agent identities identities
- echo starting ssh-agent...
- /usr/bin/ssh-add $HOME/.ssh/${^identities}
- }
- if (( $+commands[scutil] )); then
-
- _plugin__ssh_env="$HOME/.ssh/environment-$(scutil --get ComputerName)"
- else
- _plugin__ssh_env="$HOME/.ssh/environment-$HOST"
- fi
- zstyle -b :omz:plugins:ssh-agent agent-forwarding _plugin__forwarding
- if [[ ${_plugin__forwarding} == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
-
- [[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USER-screen
- elif [ -f "${_plugin__ssh_env}" ]; then
-
- . ${_plugin__ssh_env} > /dev/null
- ps x | grep ${SSH_AGENT_PID} | grep ssh-agent > /dev/null || {
- _plugin__start_agent;
- }
- else
- _plugin__start_agent;
- fi
- unfunction _plugin__start_agent
- unset _plugin__forwarding
- unset _plugin__ssh_env
|