1 # AX-ZSH: Alex' Modular ZSH Configuration
2 # gnupg.zshrc: Setup GnuPG
4 if (( $+commands[gpg2] )); then
5 # Use the gpg completions for gpg2, too
8 if ! (( $+commands[gpg])); then
9 # gpg2 is available, but no gpg: alias it!
14 # Make sure that "gpg(1)" is available.
15 (( $+commands[gpg] )) || return
19 agent_info_file="$HOME/.gnupg/agent.info-${HOST}"
21 # Validate agent info ...
22 if [[ -n "$GPG_AGENT_INFO" ]]; then
23 echo " *** Testing agent environment ..."
24 gpg-agent >/dev/null 2>&1 || unset GPG_AGENT_INFO
27 # Read environment file, when available and agent info not already set.
28 if [[ -z "$GPG_AGENT_INFO" && -r "$agent_info_file" ]]; then
29 source "$agent_info_file" 2>/dev/null
30 [[ -n "$GPG_AGENT_INFO" ]] && export GPG_AGENT_INFO
33 # Setup GnuPG agent when installed.
34 if (( $+commands[gpg-agent] )); then
35 # Start up a new GnuPP agent, when none is running/accessible:
36 if ! gpg-agent >/dev/null 2>&1; then
37 eval $(gpg-agent --daemon --write-env-file "$agent_info_file")