1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-12-23 13:46:47 +00:00
prezto/modules/gpg-agent/init.zsh

36 lines
731 B
Bash
Raw Normal View History

2012-02-01 04:37:51 +00:00
#
# Provides for an easier use of gpg-agent.
#
# Authors:
# Florian Walch <florian.walch@gmx.at>
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
2011-08-31 03:16:15 +00:00
if (( ! $+commands[gpg-agent] )); then
2012-03-28 16:19:53 +00:00
return 1
2011-08-31 03:16:15 +00:00
fi
_gpg_env="$HOME/.gnupg/gpg-agent.env"
function _gpg-agent-start {
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 [[ -s "${_gpg_env}" ]]; then
source "${_gpg_env}" > /dev/null
ps -ef | grep "${SSH_AGENT_PID}" | grep -q 'gpg-agent' || {
_gpg-agent-start
}
else
_gpg-agent-start
fi
export GPG_AGENT_INFO
export SSH_AUTH_SOCK
export SSH_AGENT_PID
export GPG_TTY="$(tty)"
2011-08-31 03:16:15 +00:00