From bd4fc28a3a56b4cdd0b85116b1b2cb07be1825e5 Mon Sep 17 00:00:00 2001 From: "bart@bambam" Date: Thu, 3 Aug 2017 21:30:31 +0200 Subject: [PATCH] screen-ssh-agent plugin added; to enable the ssh-agent within screen --- plugins/screen-ssh-agent/README.md | 13 +++++++++++++ plugins/screen-ssh-agent/screen-ssh-agent.zsh | 10 ++++++++++ 2 files changed, 23 insertions(+) create mode 100644 plugins/screen-ssh-agent/README.md create mode 100644 plugins/screen-ssh-agent/screen-ssh-agent.zsh diff --git a/plugins/screen-ssh-agent/README.md b/plugins/screen-ssh-agent/README.md new file mode 100644 index 00000000..10cf3f36 --- /dev/null +++ b/plugins/screen-ssh-agent/README.md @@ -0,0 +1,13 @@ +# screen-ssh-agent plugin + +This plugin enables the `ssh-agent` within a screen session. + +To enable it, add `screen-ssh-agent` to your plugins: + +```zsh +plugins=(... screen-ssh-agent) +``` + +## Written by +Bart Dorlandt +[https://github.com/bambam82](https://github.com/bambam82) diff --git a/plugins/screen-ssh-agent/screen-ssh-agent.zsh b/plugins/screen-ssh-agent/screen-ssh-agent.zsh new file mode 100644 index 00000000..db5c6955 --- /dev/null +++ b/plugins/screen-ssh-agent/screen-ssh-agent.zsh @@ -0,0 +1,10 @@ +if [ $SSH_AUTH_SOCK ]; then + # set up SSH agent socket symlink + export SSH_AUTH_SOCK_LINK="/tmp/ssh-$USER/agent" + if ! [ -r $(readlink -m $SSH_AUTH_SOCK_LINK) ] && [ -r $SSH_AUTH_SOCK ]; then + mkdir -p "$(dirname $SSH_AUTH_SOCK_LINK)" && + chmod go= "$(dirname $SSH_AUTH_SOCK_LINK)" && + ln -sfn $SSH_AUTH_SOCK $SSH_AUTH_SOCK_LINK + fi +fi +