Skip to content

Instantly share code, notes, and snippets.

@maxkomarychev
Last active January 22, 2016 22:13
Show Gist options
  • Save maxkomarychev/3b33cb7edfa90b6724a6 to your computer and use it in GitHub Desktop.
Save maxkomarychev/3b33cb7edfa90b6724a6 to your computer and use it in GitHub Desktop.
part of .bash_profile on OS X that launches an instance of gpg-agent per console session
# gpg-agent initialization
GPG_INFO_FILE=${HOME}/.gpg-agent-info
if [ -f "$GPG_INFO_FILE" ]; then
source "$GPG_INFO_FILE"
fi
RUNNING_DAEMON=$(ps -p $SSH_AGENT_PID 2> /dev/null | tail -n+2 | grep gpg)
if [ "$RUNNING_DAEMON" == "" ]; then
gpg-agent --daemon --enable-ssh-support --write-env-file "${HOME}/.gpg-agent-info"
fi
if [ -f "$GPG_INFO_FILE" ]; then
source "$GPG_INFO_FILE"
export GPG_AGENT_INFO
export SSH_AUTH_SOCK
export SSH_AGENT_PID
fi
export GPG_TTY=`tty`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment