Skip to content

Instantly share code, notes, and snippets.

@limed
Last active December 12, 2015 05:09
Show Gist options
  • Select an option

  • Save limed/4719738 to your computer and use it in GitHub Desktop.

Select an option

Save limed/4719738 to your computer and use it in GitHub Desktop.
Init's gpg agent if the daemon isn't running and exports the environment variables
envfile="${HOME}/.gnupg/gpg-agent.env"
if test -f "$envfile" && kill -0 $(grep GPG_AGENT_INFO "$envfile" | cut -d: -f 2) 2>/dev/null; then
eval "$(cat "$envfile")"
else
eval "$(gpg-agent --daemon --log-file=~/.gnupg/gpg.log --write-env-file "$envfile")"
fi
export GPG_AGENT_INFO # the env file does not contain the export statement
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment