Skip to content

Instantly share code, notes, and snippets.

@mrwacky42
Created December 15, 2015 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrwacky42/45a82675e9ee81405a38 to your computer and use it in GitHub Desktop.
Save mrwacky42/45a82675e9ee81405a38 to your computer and use it in GitHub Desktop.
gpgagent=$(type -path gpg-agent)
envfile="$HOME/.gnupg/gpg-agent.env"
if [ -n "$gpgagent" ]; then
agent_pid=$(grep GPG_AGENT_INFO "$envfile" | cut -d: -f 2)
if [[ -e "$envfile" ]] && kill -0 "$agent_pid" 2>/dev/null; then
eval "$(cat "$envfile")"
else
eval "$(gpg-agent --daemon --write-env-file "$envfile")"
fi
fi
unset gpgagent envfile agent_pid
export GPG_AGENT_INFO
GPG_TTY=$(tty)
export GPG_TTY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment