1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-12-21 11:51:57 +00:00

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

Close #5359
Close #7379

Co-authored-by: Will Andrews <will@firepipe.net>
Co-authored-by: zhangyc <zhangyc@fenbi.com>
This commit is contained in:
Marc Cornellà 2021-08-26 12:14:53 +02:00
parent 5a9d9553cd
commit 7692881d2a
No known key found for this signature in database
GPG key ID: 0314585E776A9C1B

View file

@ -1,5 +1,3 @@
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
_start_agent _start_agent
fi fi
() {
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 _add_identities
}
# tidy up after ourselves # tidy up after ourselves
unset _agent_forwarding _ssh_env_cache unset _agent_forwarding _ssh_env_cache