]> arthur.barton.de Git - ax-zsh.git/blobdiff - plugins/keychain/keychain.zshrc
New "hstr" plugin
[ax-zsh.git] / plugins / keychain / keychain.zshrc
index 9f8ba5f0ac97287002af016cf380d92304f81eb8..82c3b2344ddd6865088ada0e183b0de29785bfcb 100644 (file)
@@ -1,17 +1,22 @@
 # AX-ZSH: Alex' Modular ZSH Configuration
 # keychain.zshrc: Setup keychain(1)
 
+# Test if keychain(1) has already been initialized, for example in the
+# "profile" stage.
+if [[ -n "$axzsh_keychain_was_run" ]]; then
+       unset axzsh_keychain_was_run
+       return
+fi
+
 # Make sure that "keychain(1)" is installed
 (( $+commands[keychain] )) || return
 
-agents=""
-if (( $+commands[ssh-agent] )); then
-       [[ -z "$agents" ]] && agents="ssh" || agents="$agents,ssh"
-fi
-if (( $+commands[gpg-agent] )); then
-       [[ -z "$agents" ]] && agents="gpg" || agents="$agents,gpg"
-fi
+function axzsh_keychain_update() {
+       eval `keychain --eval --inherit any-once "$@"`
+}
 
-eval `keychain --agents "$agents" --eval --quick --quiet`
+[[ "$type" == "zshrc" ]] \
+       && axzsh_keychain_update --quiet --quick \
+       || axzsh_keychain_update --quiet
 
-unset agents
+unset axzsh_keychain_was_run