summaryrefslogtreecommitdiff
path: root/plugins/ssh-agent/ssh-agent.plugin.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/ssh-agent/ssh-agent.plugin.zsh')
-rw-r--r--plugins/ssh-agent/ssh-agent.plugin.zsh13
1 files changed, 9 insertions, 4 deletions
diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh
index 2d7d8a2a0..47dfef5b0 100644
--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
@@ -6,9 +6,11 @@ function _start_agent() {
if [[ -f "$ssh_env_cache" ]]; then
. "$ssh_env_cache" > /dev/null
- {
- [[ "$USERNAME" = root ]] && command ps ax || command ps x
- } | command grep ssh-agent | command grep -q $SSH_AGENT_PID && return 0
+ # Test if $SSH_AUTH_SOCK is visible
+ zmodload zsh/net/socket
+ if [[ -S "$SSH_AUTH_SOCK" ]] && zsocket "$SSH_AUTH_SOCK" 2>/dev/null; then
+ return 0
+ fi
fi
# Set a maximum lifetime for identities added to ssh-agent
@@ -96,7 +98,10 @@ else
_start_agent
fi
-_add_identities
+# Don't add identities if lazy-loading is enabled
+if ! zstyle -t :omz:plugins:ssh-agent lazy; then
+ _add_identities
+fi
unset agent_forwarding ssh_env_cache
unfunction _start_agent _add_identities