]> git.donarmstrong.com Git - zsh.git/commitdiff
add ssh-agent loading
authorDon Armstrong <don@donarmstrong.com>
Thu, 27 Dec 2012 22:38:41 +0000 (14:38 -0800)
committerDon Armstrong <don@donarmstrong.com>
Thu, 27 Dec 2012 22:38:41 +0000 (14:38 -0800)
.zsh/zshrc/64_ssh [new file with mode: 0644]

diff --git a/.zsh/zshrc/64_ssh b/.zsh/zshrc/64_ssh
new file mode 100644 (file)
index 0000000..981e6a0
--- /dev/null
@@ -0,0 +1,18 @@
+# -*- mode: sh -*-
+
+# set up ssh-agent
+if which ssh-agent >/dev/null && [ -d ~/.ssh ] &&  \
+    [ -z "$SSH_CONNECTION" ] &&  [ -z "$SSH_CLIENT" ]; then 
+    if [ -e ~/.ssh/ssh_agent_info ] && \
+       [ -n "$(awk -F '[=;]' '/^SSH_AGENT_PID/{print $2}' ~/.ssh/ssh_agent_info)" ] && \
+       kill -0 "$(awk -F '[=;]' '/^SSH_AGENT_PID/{print $2}' ~/.ssh/ssh_agent_info)" >/dev/null 2>&1; then
+       . ~/.ssh/ssh_agent_info > /dev/null
+    elif [ -e ~/.ssh/ssh_agent_info_$(hostname) ] && \
+       kill -0 "$(awk -F '[=;]' '/^SSH_AGENT_PID/{print $2}' ~/.ssh/ssh_agent_info_$(hostname))" >/dev/null 2>&1; then
+       . ~/.ssh/ssh_agent_info_$(hostname) > /dev/null
+    else
+       ssh-agent -s > ~/.ssh/ssh_agent_info_$(hostname)
+       . ~/.ssh/ssh_agent_info_$(hostname) > /dev/null
+    fi;
+fi;
+