aboutsummaryrefslogtreecommitdiffstats
path: root/zsh/profile-leeloo
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2014-08-11 23:07:45 +0200
committerJohannes Löthberg <johannes@kyriasis.com>2014-08-11 23:07:45 +0200
commit9b1c49e94726a5ae85db89a211c8ebf3290fe87c (patch)
treebdbaebe54af3de42b6cec2a8f46f4cbcd64d54bd /zsh/profile-leeloo
parent2ecc457acb953ab8e4f8d55b6b4d9f20e8af6fa8 (diff)
downloaddotfiles-9b1c49e94726a5ae85db89a211c8ebf3290fe87c.tar.xz
zprofile: Move ssh/gpg-agent things to profile-leeloo
Diffstat (limited to 'zsh/profile-leeloo')
-rw-r--r--zsh/profile-leeloo23
1 files changed, 23 insertions, 0 deletions
diff --git a/zsh/profile-leeloo b/zsh/profile-leeloo
new file mode 100644
index 0000000..c74e1f7
--- /dev/null
+++ b/zsh/profile-leeloo
@@ -0,0 +1,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: