summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ebe1d87)
Now keychain(1) is called in the "profile" stage for login shells
already, to make sure that it runs before any other local scripts
test, use, or update the SSH and GnuPG agents.
And in addition this patch introduces the new axzsh_keychain_update
function, which can be used to update the SSH and GnuPG agent
information at any time.
--- /dev/null
+# AX-ZSH: Alex' Modular ZSH Configuration
+# keychain.zprofile: Setup keychain(1)
+
+# Initialize keychain(1) as soon as possible ("profile") stage, but run it
+# in all sessions, in non-login shells, too. So call the "zshrc" script here
+# and set a flag that keychain(1) has been initialized already.
+source $(dirname "$0")/keychain.zshrc && axzsh_keychain_was_run=1
# AX-ZSH: Alex' Modular ZSH Configuration
# keychain.zshrc: Setup keychain(1)
# 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
# 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() {
+ local 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
+ eval `keychain --agents "$agents" --eval --inherit any-once "$@"`
+}
-eval `keychain --agents "$agents" --eval --inherit any-once --quick --quiet`
+[[ "$type" == "zshrc" ]] \
+ && axzsh_keychain_update --quiet --quick \
+ || axzsh_keychain_update --quiet
+unset axzsh_keychain_was_run