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!
13 # Make sure that "gpg(1)" is available.
14 (( $+commands[gpg] )) || return 1
19 agent_info_file="$HOME/.gnupg/agent.info-${HOST}"
21 # Validate agent info ...
22 if [[ -n "$GPG_AGENT_INFO" ]]; then
23 gpg-agent >/dev/null 2>&1 || unset GPG_AGENT_INFO
26 # Read environment file, when available and agent info not already set.
27 if [[ -z "$GPG_AGENT_INFO" && -r "$agent_info_file" ]]; then
28 source "$agent_info_file" 2>/dev/null
29 [[ -n "$GPG_AGENT_INFO" ]] && export GPG_AGENT_INFO
32 # Setup GnuPG agent when installed.
33 if (( $+commands[gpg-agent] )); then
34 # Start up a new GnuPP agent, when none is running/accessible:
35 if ! gpg-agent >/dev/null 2>&1; then
36 eval $(gpg-agent --daemon --write-env-file "$agent_info_file")