summaryrefslogtreecommitdiffstats
path: root/gpg-agent.sh
blob: 576dc497c764387d11cf556e3638622b46aa6c3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh
#----------------------------------------------------
# Version:      0.1.0
# Author:       Florian "Bluewind" Pritz <f-p@gmx.at>
#
# Copyright (C) 2008-2009 Florian Pritz
#
# Licensed under GNU General Public License v3
#   (see COPYING for full license text)
#    
#----------------------------------------------------
# make working with the agent easier and prevent
# starting multiple agents
#----------------------------------------------------
initgpg(){
  [ -f "$XDG_CONFIG_HOME/disable-gpg-agent" ] && return 0
  envfile="${HOME}/.gpginfo"
  if test -f ${envfile} && kill -0 $(cut -d: -f 2 ${envfile} | head -n 1) 2>/dev/null; then
    eval $(cat ${envfile})
	else
    eval `/usr/bin/gpg-agent --daemon --enable-ssh-support --write-env-file ${envfile}`
  fi
  export GPG_AGENT_INFO
  export SSH_AUTH_SOCK
  export SSH_AGENT_PID
}
initgpg