gpg-agent.plugin.zsh 546 B

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