1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-11-14 21:11:13 +00:00
prezto/plugins/gpg-agent/init.zsh

32 lines
642 B
Bash
Raw Normal View History

2011-08-31 03:16:15 +00:00
# Based on ssh-agent code.
2011-08-31 03:16:15 +00:00
local GPG_ENV="$HOME/.gnupg/gpg-agent.env"
2011-08-31 03:16:15 +00:00
if (( ! $+commands[gpg-agent] )); then
return
fi
function _gpg-agent-start() {
/usr/bin/env gpg-agent --daemon --enable-ssh-support --write-env-file "${GPG_ENV}" > /dev/null
chmod 600 "${GPG_ENV}"
source "${GPG_ENV}" > /dev/null
}
2011-08-31 03:16:15 +00:00
# Source GPG agent settings, if applicable.
if [[ -f "${GPG_ENV}" ]]; then
source "${GPG_ENV}" > /dev/null
ps -ef | grep "${SSH_AGENT_PID}" | grep gpg-agent > /dev/null || {
_gpg-agent-start;
}
else
2011-08-31 03:16:15 +00:00
_gpg-agent-start;
fi
export GPG_AGENT_INFO
export SSH_AUTH_SOCK
export SSH_AGENT_PID
GPG_TTY=$(tty)
export GPG_TTY
2011-08-31 03:16:15 +00:00