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 +