40b7f2099d393950e26d1a9720743e161b1abe49
- Author
- gwjo <gowen72@gmail.com>
- Committer
- gwjo <gowen72@gmail.com>
- Date
Message
Add support for loading mulitple identities
Diff
1diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh
2index 0f5b03d26fa5312f710d3eba16cbc7bbd1dfbdff..c4e92a1fe00403782e7eacbb0fb5009b5f65629a 100644
3--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
4+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
5@@ -6,6 +6,11 @@
6 #
7 # zstyle :omz:plugins:ssh-agent agent-forwarding on
8 #
9+# To load multiple identies use the identities style, For
10+# example:
11+#
12+# zstyle :omz:plugins:ssh-agent id_rsa id_rsa2 id_github
13+#
14 #
15 # CREDITS
16 #
17@@ -21,17 +26,23 @@ local _plugin__forwarding
18
19 function _plugin__start_agent()
20 {
21+ local -a identities
22+
23+ # start ssh-agent and setup environment
24 /usr/bin/env ssh-agent | sed 's/^echo/#echo/' > ${_plugin__ssh_env}
25 chmod 600 ${_plugin__ssh_env}
26 . ${_plugin__ssh_env} > /dev/null
27- /usr/bin/ssh-add;
28+
29+ # load identies
30+ zstyle -a :omz:plugins:ssh-agent identities identities
31+ echo starting...
32+ /usr/bin/ssh-add $HOME/.ssh/${^identities}
33 }
34
35 # test if agent-forwarding is enabled
36 zstyle -b :omz:plugins:ssh-agent agent-forwarding _plugin__forwarding
37-if [[ ${_plugin__forwarding} == "yes" && -z $SSH_AGENT_PID && -n "$SSH_AUTH_SOCK" ]]; then
38- # No PID but a AUTH_SOCK means agent forwarding is enabled
39- # Add a nifty symlink for screen/tmux
40+if [[ ${_plugin__forwarding} == "yes" && -n "$SSH_AUTH_SOCK" ]]; then
41+ # Add a nifty symlink for screen/tmux if agent forwarding
42 [[ -L $SSH_AUTH_SOCK ]] || ln -sf "$SSH_AUTH_SOCK" /tmp/ssh-agent-$USER-screen
43
44 elif [ -f "${_plugin__ssh_env}" ]; then