ssh-agent: autoload identities in one go (#7507)
With this PR the ssh-agent plugin loads all identities which are not yet
loaded in a single call to ssh-add. If a passphrase is shared between
loaded identities it only needs to be entered once.
Fixes #7506
Diff
1diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh
2index 2a860f3aa5a5e1fe0df8fe265b91a596a48c6439..1cc5630e1428d52638b7d18a1d87c01de3f3da75 100644
3--- a/plugins/ssh-agent/ssh-agent.plugin.zsh
4+++ b/plugins/ssh-agent/ssh-agent.plugin.zsh
5@@ -13,7 +13,7 @@ function _start_agent() {
6 7 function _add_identities() {
8 local id line sig
9- local -a identities loaded signatures
10+ local -a identities loaded not_loaded signatures
11 zstyle -a :omz:plugins:ssh-agent identities identities
1213 # check for .ssh folder presence
14@@ -33,8 +33,10 @@ function _add_identities() {
15 for sig in $signatures; do
16 id="$(cut -f2 <<< $sig)"
17 sig="$(cut -f1 <<< $sig)"
18- [[ ${loaded[(I)$sig]} -le 0 ]] && ssh-add $HOME/.ssh/$id
19+ [[ ${loaded[(I)$sig]} -le 0 ]] && not_loaded+="$HOME/.ssh/$id"
20 done
21+
22+ if [[ -n "$not_loaded" ]] && ssh-add ${^not_loaded}
23 }
2425 # Get the filename to store/lookup the environment from