diff options
author | Andreas <andreas@galauner.de> | 2019-01-14 16:42:14 +0100 |
---|---|---|
committer | Marc Cornellà <marc.cornella@live.com> | 2019-01-14 16:42:14 +0100 |
commit | 9329efd2522b3eaba5f6d9d53e41c090eb6b3c92 (patch) | |
tree | 10824b24b45248c26f40ddcb1862de58c11c619f | |
parent | 2a603856598eafc3c8a0bde80f8a885d2a81dfee (diff) | |
download | zsh-9329efd2522b3eaba5f6d9d53e41c090eb6b3c92.tar.gz zsh-9329efd2522b3eaba5f6d9d53e41c090eb6b3c92.tar.bz2 zsh-9329efd2522b3eaba5f6d9d53e41c090eb6b3c92.zip |
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
-rw-r--r-- | plugins/ssh-agent/ssh-agent.plugin.zsh | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/plugins/ssh-agent/ssh-agent.plugin.zsh b/plugins/ssh-agent/ssh-agent.plugin.zsh index 2a860f3aa..1cc5630e1 100644 --- a/plugins/ssh-agent/ssh-agent.plugin.zsh +++ b/plugins/ssh-agent/ssh-agent.plugin.zsh @@ -13,7 +13,7 @@ function _start_agent() { function _add_identities() { local id line sig - local -a identities loaded signatures + local -a identities loaded not_loaded signatures zstyle -a :omz:plugins:ssh-agent identities identities # check for .ssh folder presence @@ -33,8 +33,10 @@ function _add_identities() { for sig in $signatures; do id="$(cut -f2 <<< $sig)" sig="$(cut -f1 <<< $sig)" - [[ ${loaded[(I)$sig]} -le 0 ]] && ssh-add $HOME/.ssh/$id + [[ ${loaded[(I)$sig]} -le 0 ]] && not_loaded+="$HOME/.ssh/$id" done + + if [[ -n "$not_loaded" ]] && ssh-add ${^not_loaded} } # Get the filename to store/lookup the environment from |