Diff
1diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md
2index 1d6914ec6ba4ef08560f3328c51d883a296b843d..fa6a996d4aa07741a692e957368bc6d10ac5f360 100644
3--- a/plugins/ssh-agent/README.md
4+++ b/plugins/ssh-agent/README.md
5@@ -13,28 +13,24 @@ plugins=(... ssh-agent)
6
7 **IMPORTANT: put these settings _before_ the line that sources oh-my-zsh**
8
9+### `agent-forwarding`
10+
11 To enable **agent forwarding support** add the following to your zshrc file:
12
13 ```zsh
14-zstyle :omz:plugins:ssh-agent agent-forwarding on
15+zstyle :omz:plugins:ssh-agent agent-forwarding yes
16 ```
17
18-----
19+### `helper`
20
21-To **NOT load any identities on start** use the `lazy` setting. This is particularly
22-useful when combined with the `AddKeysToAgent` setting (available since OpenSSH 7.2),
23-since it allows to enter the password only on first use. _NOTE: you can know your
24-OpenSSH version with `ssh -V`._
25+To set an **external helper** to ask for the passwords and possibly store
26+them in the system keychain use the `helper` style. For example:
27
28 ```zsh
29-zstyle :omz:plugins:ssh-agent lazy yes
30+zstyle :omz:plugins:ssh-agent helper ksshaskpass
31 ```
32
33-You can enable `AddKeysToAgent` by passing `-o AddKeysToAgent=yes` to the `ssh` command,
34-or by adding `AddKeysToAgent yes` to your `~/.ssh/config` file [1].
35-See the [OpenSSH 7.2 Release Notes](http://www.openssh.com/txt/release-7.2).
36-
37-----
38+### `identities`
39
40 To **load multiple identities** use the `identities` style (**this has no effect
41 if the `lazy` setting is enabled**). For example:
42@@ -52,7 +48,22 @@ zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/id_rsa ~/.config/ssh/id_r
43 zstyle :omz:plugins:ssh-agent identities ~/.config/ssh/{id_rsa,id_rsa2,id_github}
44 ```
45
46-----
47+### `lazy`
48+
49+To **NOT load any identities on start** use the `lazy` setting. This is particularly
50+useful when combined with the `AddKeysToAgent` setting (available since OpenSSH 7.2),
51+since it allows to enter the password only on first use. _NOTE: you can know your
52+OpenSSH version with `ssh -V`._
53+
54+```zsh
55+zstyle :omz:plugins:ssh-agent lazy yes
56+```
57+
58+You can enable `AddKeysToAgent` by passing `-o AddKeysToAgent=yes` to the `ssh` command,
59+or by adding `AddKeysToAgent yes` to your `~/.ssh/config` file [1].
60+See the [OpenSSH 7.2 Release Notes](http://www.openssh.com/txt/release-7.2).
61+
62+### `lifetime`
63
64 To **set the maximum lifetime of the identities**, use the `lifetime` style.
65 The lifetime may be specified in seconds or as described in sshd_config(5)
66@@ -62,7 +73,15 @@ The lifetime may be specified in seconds or as described in sshd_config(5)
67 zstyle :omz:plugins:ssh-agent lifetime 4h
68 ```
69
70-----
71+### `quiet`
72+
73+To silence the plugin, use the following setting:
74+
75+```zsh
76+zstyle :omz:plugins:ssh-agent quiet yes
77+```
78+
79+### `ssh-add-args`
80
81 To **pass arguments to the `ssh-add` command** that adds the identities on startup,
82 use the `ssh-add-args` setting. You can pass multiple arguments separated by spaces:
83@@ -80,15 +99,6 @@ ssh-add -K -c -a /run/user/1000/ssh-auth <identities>
84
85 For valid `ssh-add` arguments run `ssh-add --help` or `man ssh-add`.
86
87-----
88-
89-To set an **external helper** to ask for the passwords and possibly store
90-them in the system keychain use the `helper` style. For example:
91-
92-```zsh
93-zstyle :omz:plugins:ssh-agent helper ksshaskpass
94-```
95-
96 ## Credits
97
98 Based on code from Joseph M. Reagle: https://www.cygwin.com/ml/cygwin/2001-06/msg00537.html
99diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh
100index 47dfef5b064402d1c4c47e37c7f59a8ec1fa618f..0d6a35b3524dfe42ded4e0ed8a7957e8b8b2dd42 100644
101--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
102+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
103@@ -18,7 +18,7 @@ function _start_agent() {
104 zstyle -s :omz:plugins:ssh-agent lifetime lifetime
105
106 # start ssh-agent and setup environment
107- echo Starting ssh-agent...
108+ zstyle -t :omz:plugins:ssh-agent quiet || echo >&2 "Starting ssh-agent ..."
109 ssh-agent -s ${lifetime:+-t} ${lifetime} | sed '/^echo/d' >! "$ssh_env_cache"
110 chmod 600 "$ssh_env_cache"
111 . "$ssh_env_cache" > /dev/null
112@@ -78,7 +78,7 @@ function _add_identities() {
113
114 if [[ -n "$helper" ]]; then
115 if [[ -z "${commands[$helper]}" ]]; then
116- echo "ssh-agent: the helper '$helper' has not been found."
117+ echo >&2 "ssh-agent: the helper '$helper' has not been found."
118 else
119 SSH_ASKPASS="$helper" ssh-add "${args[@]}" ${^not_loaded} < /dev/null
120 return $?
121@@ -88,11 +88,9 @@ function _add_identities() {
122 ssh-add "${args[@]}" ${^not_loaded}
123 }
124
125-# test if agent-forwarding is enabled
126-zstyle -b :omz:plugins:ssh-agent agent-forwarding agent_forwarding
127-
128-# Add a nifty symlink for screen/tmux if agent forwarding
129-if [[ $agent_forwarding = "yes" && -n "$SSH_AUTH_SOCK" && ! -L "$SSH_AUTH_SOCK" ]]; then
130+# Add a nifty symlink for screen/tmux if agent forwarding is enabled
131+if zstyle -t :omz:plugins:ssh-agent agent-forwarding \
132+ && [[ -n "$SSH_AUTH_SOCK" && ! -L "$SSH_AUTH_SOCK" ]]; then
133 ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USERNAME-screen
134 else
135 _start_agent