diff options
author | Marc Cornellà <hello@mcornella.com> | 2021-08-26 12:14:53 +0200 |
---|---|---|
committer | Marc Cornellà <hello@mcornella.com> | 2021-08-26 14:54:17 +0200 |
commit | 7692881d2a61a4ba47eeef5d7827c0d2cb896def (patch) | |
tree | bcce601a862a2a7aa685c45fd7a1aeaf1358f18f | |
parent | 5a9d9553cd6861d80cc958132ab5af40fe661ac4 (diff) | |
download | zsh-7692881d2a61a4ba47eeef5d7827c0d2cb896def.tar.gz zsh-7692881d2a61a4ba47eeef5d7827c0d2cb896def.tar.bz2 zsh-7692881d2a61a4ba47eeef5d7827c0d2cb896def.zip |
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>
-rw-r--r-- | plugins/ssh-agent/ssh-agent.plugin.zsh | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 9bc2e8a21..acad4e83e 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -1,5 +1,3 @@ -typeset _agent_forwarding _ssh_env_cache - function _start_agent() { local lifetime zstyle -s :omz:plugins:ssh-agent lifetime lifetime @@ -97,7 +95,23 @@ else _start_agent 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 unset _agent_forwarding _ssh_env_cache |