Diff
1diff --git a/plugins/ssh-agent/README.md b/plugins/ssh-agent/README.md
2index 0b96d9bb507833d703ea54e988dc9825b07c78f0..8765a9c7ea9aaaa7229996570aef96317bf77930 100644
3--- a/plugins/ssh-agent/README.md
4+++ b/plugins/ssh-agent/README.md
5@@ -9,7 +9,7 @@ To enable it, add `ssh-agent` to your plugins:
6 plugins=(... ssh-agent)
7 ```
8
9-## Instructions
10+## Settings
11
12 **IMPORTANT: put these settings _before_ the line that sources oh-my-zsh**
13
14@@ -19,12 +19,16 @@ To enable **agent forwarding support** add the following to your zshrc file:
15 zstyle :omz:plugins:ssh-agent agent-forwarding on
16 ```
17
18+----
19+
20 To **load multiple identities** use the `identities` style, For example:
21
22 ```zsh
23 zstyle :omz:plugins:ssh-agent identities id_rsa id_rsa2 id_github
24 ```
25
26+----
27+
28 To **set the maximum lifetime of the identities**, use the `lifetime` style.
29 The lifetime may be specified in seconds or as described in sshd_config(5)
30 (see _TIME FORMATS_). If left unspecified, the default lifetime is forever.
31@@ -33,6 +37,24 @@ The lifetime may be specified in seconds or as described in sshd_config(5)
32 zstyle :omz:plugins:ssh-agent lifetime 4h
33 ```
34
35+----
36+
37+To **pass arguments to the `ssh-add` command** that adds the identities on startup,
38+use the `ssh-add-args` setting. You can pass multiple arguments separated by spaces:
39+
40+```zsh
41+zstyle :omz:plugins:ssh-agent ssh-add-args -K -c -a /run/user/1000/ssh-auth
42+```
43+
44+These will then be passed the the `ssh-add` call as if written directly. The example
45+above will turn into:
46+
47+```zsh
48+ssh-add -K -c -a /run/user/1000/ssh-auth <identities>
49+```
50+
51+For valid `ssh-add` arguments run `ssh-add --help` or `man ssh-add`.
52+
53 ## Credits
54
55 Based on code from Joseph M. Reagle: https://www.cygwin.com/ml/cygwin/2001-06/msg00537.html
56diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh
57index 6ab041c2144d35d26ceef81f6305468b82b674cf..430647135d805a90fd3102ba15c5facea33c8897 100644
58--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
59+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
60@@ -48,7 +48,9 @@ function _add_identities() {
61 fi
62 done
63
64- [[ -n "$not_loaded" ]] && ssh-add ${^not_loaded}
65+ local args
66+ zstyle -a :omz:plugins:ssh-agent ssh-add-args args
67+ [[ -n "$not_loaded" ]] && ssh-add "${args[@]}" ${^not_loaded}
68 }
69
70 # Get the filename to store/lookup the environment from