diff --git a/plugins/keychain/keychain.plugin.zsh b/plugins/keychain/keychain.plugin.zsh index f122f7982..d83893c10 100644 --- a/plugins/keychain/keychain.plugin.zsh +++ b/plugins/keychain/keychain.plugin.zsh @@ -19,8 +19,18 @@ function { # load additional options zstyle -a :omz:plugins:keychain options options - # start keychain... - keychain ${^options:-} --agents ${agents:-gpg} ${^identities} --host $SHORT_HOST + # Check keychain version to decide whether to use --agents + local version_string=$(keychain --version 2>&1 | head -n 2 | tail -n 1 | cut -d ' ' -f 4) + local -a version_parts=(${(s:.:)version_string}) + local major=${version_parts[1]:-0} + local minor=${version_parts[2]:-0} + + # start keychain, only use --agents for versions below 2.9.0 + if (( major < 2 || (major == 2 && minor < 9) )); then + keychain ${^options:-} --agents ${agents:-gpg} ${^identities} --host $SHORT_HOST + else + keychain ${^options:-} ${^identities} --host $SHORT_HOST + fi # Get the filenames to store/lookup the environment from _keychain_env_sh="$HOME/.keychain/$SHORT_HOST-sh"