Unverified Commit 7692881d authored by Marc Cornellà's avatar Marc Cornellà
Browse files

feat(ssh-agent): only start ssh-agent once (#5359)



Close #5359
Close #7379
Co-authored-by: default avatarWill Andrews <will@firepipe.net>
Co-authored-by: default avatarzhangyc <zhangyc@fenbi.com>
parent 5a9d9553
typeset _agent_forwarding _ssh_env_cache
function _start_agent() { function _start_agent() {
local lifetime local lifetime
zstyle -s :omz:plugins:ssh-agent lifetime lifetime zstyle -s :omz:plugins:ssh-agent lifetime lifetime
...@@ -97,7 +95,23 @@ else ...@@ -97,7 +95,23 @@ else
_start_agent _start_agent
fi fi
_add_identities () {
emulate -L zsh
command mkdir "$ZSH_CACHE_DIR/ssh-agent.lock" 2>/dev/null || return
trap "
ret=\$?
command rm -rf '$ZSH_CACHE_DIR/ssh-agent.lock'
unset _agent_forwarding _ssh_env_cache
unfunction _start_agent _add_identities 2>/dev/null
return \$ret
" EXIT INT QUIT
_add_identities
}
# tidy up after ourselves # tidy up after ourselves
unset _agent_forwarding _ssh_env_cache unset _agent_forwarding _ssh_env_cache
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment