3e7998aec33ff7551d06d4510f9e8769aab5db93

Author
Marc Cornellà <hello@mcornella.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

Revert "ssh-agent: improvements (#6309)"

This reverts commit a206271460ce49e842b1b410c0424b8c9a0a3d14.

Diff

 1diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md
 2index aa96f9cc9eeb413238d71100a44bb8e89b1ca332..8765a9c7ea9aaaa7229996570aef96317bf77930 100644
 3--- a/plugins/ssh-agent/README.md
 4+++ b/plugins/ssh-agent/README.md
 5@@ -19,17 +19,9 @@ To enable **agent forwarding support** add the following to your zshrc file:
 6 zstyle :omz:plugins:ssh-agent agent-forwarding on
 7 ```
 8 
 9-To **NOT load any identities on start** use the `lazy` style.
10-This is particularly usefull when combined with the AddKeysToAgent
11-(available from OpenSSH 7.2), since it allows to enter the password only
12-on first use.
13-
14-```zsh
15-zstyle :omz:plugins:ssh-agent lazy yes
16-```
17+----
18 
19-To **load multiple identities** use the `identities` style. This have no
20-effect if `lazy` is enabled.
21+To **load multiple identities** use the `identities` style, For example:
22 
23 ```zsh
24 zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github
25diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh
26index 494cf1393db61fffda3cec6f473df6f1b9d738fa..d45406f63837dfc7adc770e73855df4aa436e3da 100644
27--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
28+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
29@@ -1,16 +1,4 @@
30-lockdir=/tmp/oh-my-zsh-ssh-agent.lock
31-
32-while true; do
33-    if mkdir "$lockdir" 2>/dev/null
34-    then    # directory did not exist, but was created successfully
35-        trap 'rm -rf "$lockdir"' 0    # remove directory when script finishes
36-        break    # continue with script
37-    else
38-        sleep 0.1  # sleep for 0.2 and try again
39-    fi
40-done
41-
42-typeset _ssh_env_cache
43+typeset _agent_forwarding _ssh_env_cache
44 
45 function _start_agent() {
46 	local lifetime
47@@ -68,7 +56,10 @@ function _add_identities() {
48 # Get the filename to store/lookup the environment from
49 _ssh_env_cache="$HOME/.ssh/environment-$SHORT_HOST"
50 
51-if zstyle -t :omz:plugins:ssh-agent agent-forwarding && [[ -n "$SSH_AUTH_SOCK" ]]; then
52+# test if agent-forwarding is enabled
53+zstyle -b :omz:plugins:ssh-agent agent-forwarding _agent_forwarding
54+
55+if [[ $_agent_forwarding == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
56 	# Add a nifty symlink for screen/tmux if agent forwarding
57 	[[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen
58 elif [[ -f "$_ssh_env_cache" ]]; then
59@@ -82,16 +73,12 @@ elif [[ -f "$_ssh_env_cache" ]]; then
60 	ps $FILTER | grep ssh-agent | grep -q $SSH_AGENT_PID || {
61 		_start_agent
62 	}
63-elif [[ -d $HOME/.ssh ]]; then
64+else
65 	_start_agent
66 fi
67 
68-if ! zstyle -t :omz:plugins:ssh-agent lazy; then
69-	_add_identities
70-fi
71+_add_identities
72 
73 # tidy up after ourselves
74-unset _ssh_env_cache
75+unset _agent_forwarding _ssh_env_cache
76 unfunction _start_agent _add_identities
77-
78-rm -rf "$lockdir"