aboutsummaryrefslogtreecommitdiffstats
path: root/zsh/profile-leeloo
blob: c74e1f70e5b33bb8cfb926afa1d6611c5df28474 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function {
	local envfile="$XDG_RUNTIME_DIR"/gpg-agent.env
	if [[ -e "$envfile" ]] && kill -0 $(cut -d':' -f2 <"$envfile") &>/dev/null; then
		source "$envfile"
	else
		source <(gpg-agent --daemon --write-env-file "$envfile")
		export GPG_AGENT_INFO
	fi
}

function {
	local envfile="$XDG_RUNTIME_DIR"/ssh-agent.env
	local pid=$(awk -F'[=;]' 'FNR == 2 {print $2}' "$envfile" 2>/dev/null)

	if [[ -n "$pid" ]] && kill -0 "$pid" &>/dev/null; then
		source "$envfile" >/dev/null
	else
		ssh-agent > "$envfile"
		source "$envfile" >/dev/null
	fi
}

# vim: ft=zsh: