summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Walch <florian.walch@gmx.at>2010-10-15 16:50:39 +0200
committerFlorian Walch <florian.walch@gmx.at>2010-10-15 16:50:39 +0200
commit60b560fc9ace116cde7e56954f386b1098751648 (patch)
tree8d7afd7c2b1e3dd7e7fd7ec188bbe11f6a9a4b6a
parentdc12853b0c3e5af9e42f44cb9efdf57d44d20711 (diff)
downloadzsh-60b560fc9ace116cde7e56954f386b1098751648.tar.gz
zsh-60b560fc9ace116cde7e56954f386b1098751648.tar.bz2
zsh-60b560fc9ace116cde7e56954f386b1098751648.zip
Added gpg-agent plugin
Based on ssh-agent plugin.
-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