df200c943a1dcfa040f334b8006e495af39205fd

Author
Zachary Craig <zack@zack6849.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(keychain): support >2.9 (#13189)

Co-authored-by: Carlo Sala <carlosalag@protonmail.com>

Diff

 1diff --git a/plugins/keychain/keychain.plugin.zsh b/plugins/keychain/keychain.plugin.zsh
 2index f122f79826299d855c37768cc39b701b6428f23b..8caf671f55c2763ae3fa8ce0633d4e5e32b71bfb 100644
 3--- a/plugins/keychain/keychain.plugin.zsh
 4+++ b/plugins/keychain/keychain.plugin.zsh
 5@@ -19,8 +19,15 @@ function {
 6 	# load additional options
 7 	zstyle -a :omz:plugins:keychain options options
 8 
 9-	# start keychain...
10-	keychain ${^options:-} --agents ${agents:-gpg} ${^identities} --host $SHORT_HOST
11+	# Check keychain version to decide whether to use --agents
12+	local version_string=$(keychain --version 2>&1 | head -n 2 | tail -n 1 | cut -d ' ' -f 4)
13+  # start keychain, only use --agents for versions below 2.9.0
14+	autoload -Uz is-at-least
15+	if is-at-least 2.9 "$version_string"; then
16+		keychain ${^options:-} --agents ${agents:-gpg} ${^identities} --host $SHORT_HOST
17+	else
18+		keychain ${^options:-} ${^identities} --host $SHORT_HOST
19+	fi
20 
21 	# Get the filenames to store/lookup the environment from
22 	_keychain_env_sh="$HOME/.keychain/$SHORT_HOST-sh"