]> git.rmz.io Git - dotfiles.git/blob - zsh/plugins/gpg-agent/gpg-agent.plugin.zsh
mv aliases
[dotfiles.git] / zsh / plugins / gpg-agent / gpg-agent.plugin.zsh
1 # Based on ssh-agent code
2
3 local GPG_ENV=$HOME/.gnupg/gpg-agent.env
4
5 function start_agent {
6 /usr/bin/env gpg-agent --daemon --enable-ssh-support --write-env-file ${GPG_ENV} > /dev/null
7 chmod 600 ${GPG_ENV}
8 . ${GPG_ENV} > /dev/null
9 }
10
11 # Source GPG agent settings, if applicable
12 if [ -f "${GPG_ENV}" ]; then
13 . ${GPG_ENV} > /dev/null
14 ps -ef | grep ${SSH_AGENT_PID} | grep gpg-agent > /dev/null || {
15 start_agent;
16 }
17 else
18 start_agent;
19 fi
20
21 export GPG_AGENT_INFO
22 export SSH_AUTH_SOCK
23 export SSH_AGENT_PID
24
25 GPG_TTY=$(tty)
26 export GPG_TTY