summaryrefslogtreecommitdiff
path: root/plugins/gpg-agent
diff options
context:
space:
mode:
authorPete Clark <pete.clark@gmail.com>2011-05-29 18:51:32 -0400
committerPete Clark <pete.clark@gmail.com>2011-05-29 18:51:32 -0400
commit8411a39a869cd80474e3898f2fa4f204599b943a (patch)
treea77b33ce1d48249a405c8c9e66936351d00d637f /plugins/gpg-agent
parent1e86678f9d3c8c979ff8d3c8b5aac19e9e611441 (diff)
parent142c03dbd223683fd2d99f878b68f0f075cf33fb (diff)
downloadzsh-8411a39a869cd80474e3898f2fa4f204599b943a.tar.gz
zsh-8411a39a869cd80474e3898f2fa4f204599b943a.tar.bz2
zsh-8411a39a869cd80474e3898f2fa4f204599b943a.zip
Merge branch 'master' of git://github.com/robbyrussell/oh-my-zsh into taskwarrior-plugin
Diffstat (limited to 'plugins/gpg-agent')
-rw-r--r--plugins/gpg-agent/gpg-agent.plugin.zsh26
1 files changed, 26 insertions, 0 deletions
diff --git a/plugins/gpg-agent/gpg-agent.plugin.zsh b/plugins/gpg-agent/gpg-agent.plugin.zsh
new file mode 100644
index 000000000..8cc71fd57
--- /dev/null
+++ b/plugins/gpg-agent/gpg-agent.plugin.zsh
@@ -0,0 +1,26 @@
+# Based on ssh-agent code
+
+local GPG_ENV=$HOME/.gnupg/gpg-agent.env
+
+function start_agent {
+ /usr/bin/env gpg-agent --daemon --enable-ssh-support --write-env-file ${GPG_ENV} > /dev/null
+ chmod 600 ${GPG_ENV}
+ . ${GPG_ENV} > /dev/null
+}
+
+# Source GPG agent settings, if applicable
+if [ -f "${GPG_ENV}" ]; then
+ . ${GPG_ENV} > /dev/null
+ ps -ef | grep ${SSH_AGENT_PID} | grep gpg-agent > /dev/null || {
+ start_agent;
+ }
+else
+ start_agent;
+fi
+
+export GPG_AGENT_INFO
+export SSH_AUTH_SOCK
+export SSH_AGENT_PID
+
+GPG_TTY=$(tty)
+export GPG_TTY