Commit 9329efd2 authored by Andreas's avatar Andreas Committed by Marc Cornellà
Browse files

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
parent 2a603856
...@@ -13,7 +13,7 @@ function _start_agent() { ...@@ -13,7 +13,7 @@ function _start_agent() {
function _add_identities() { function _add_identities() {
local id line sig local id line sig
local -a identities loaded signatures local -a identities loaded not_loaded signatures
zstyle -a :omz:plugins:ssh-agent identities identities zstyle -a :omz:plugins:ssh-agent identities identities
# check for .ssh folder presence # check for .ssh folder presence
...@@ -33,8 +33,10 @@ function _add_identities() { ...@@ -33,8 +33,10 @@ function _add_identities() {
for sig in $signatures; do for sig in $signatures; do
id="$(cut -f2 <<< $sig)" id="$(cut -f2 <<< $sig)"
sig="$(cut -f1 <<< $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 done
if [[ -n "$not_loaded" ]] && ssh-add ${^not_loaded}
} }
# Get the filename to store/lookup the environment from # Get the filename to store/lookup the environment from
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment