2012-02-01 05:37:51 +01:00
|
|
|
#
|
|
|
|
# Provides for an easier use of gpg-agent.
|
|
|
|
#
|
|
|
|
# Authors:
|
|
|
|
# Florian Walch <florian.walch@gmx.at>
|
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
|
|
#
|
2010-10-15 16:50:39 +02:00
|
|
|
|
2012-07-23 21:00:44 +02:00
|
|
|
# Return if requirements are not found.
|
2011-08-31 05:16:15 +02:00
|
|
|
if (( ! $+commands[gpg-agent] )); then
|
2012-03-28 18:19:53 +02:00
|
|
|
return 1
|
2011-08-31 05:16:15 +02:00
|
|
|
fi
|
|
|
|
|
2012-03-09 03:51:42 +01:00
|
|
|
_gpg_env="$HOME/.gnupg/gpg-agent.env"
|
|
|
|
|
2012-03-23 19:57:51 +01:00
|
|
|
function _gpg-agent-start {
|
2012-09-30 23:19:34 +02:00
|
|
|
local ssh_support
|
|
|
|
|
|
|
|
zstyle -b ':prezto:module:gpg-agent' ssh-support 'ssh_support' \
|
|
|
|
|| ssh_support=''
|
|
|
|
|
|
|
|
gpg-agent \
|
|
|
|
--daemon ${ssh_support:+'--enable-ssh-support'}
|
|
|
|
--write-env-file "${_gpg_env}" > /dev/null
|
|
|
|
|
2012-03-07 18:01:05 +01:00
|
|
|
chmod 600 "${_gpg_env}"
|
2012-03-08 00:05:01 +01:00
|
|
|
source "${_gpg_env}" > /dev/null
|
2010-10-15 16:50:39 +02:00
|
|
|
}
|
|
|
|
|
2011-08-31 05:16:15 +02:00
|
|
|
# Source GPG agent settings, if applicable.
|
2012-04-16 20:21:29 +02:00
|
|
|
if [[ -s "${_gpg_env}" ]]; then
|
2012-03-08 00:05:01 +01:00
|
|
|
source "${_gpg_env}" > /dev/null
|
2012-03-07 18:01:05 +01:00
|
|
|
ps -ef | grep "${SSH_AGENT_PID}" | grep -q 'gpg-agent' || {
|
2012-02-01 05:42:01 +01:00
|
|
|
_gpg-agent-start
|
2010-10-15 16:50:39 +02:00
|
|
|
}
|
|
|
|
else
|
2012-02-01 05:42:01 +01:00
|
|
|
_gpg-agent-start
|
2010-10-15 16:50:39 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
export GPG_AGENT_INFO
|
|
|
|
export SSH_AUTH_SOCK
|
|
|
|
export SSH_AGENT_PID
|
2012-02-01 05:42:01 +01:00
|
|
|
export GPG_TTY="$(tty)"
|
2011-08-31 05:16:15 +02:00
|
|
|
|