ssh-add.zsh 616 B

12345678910111213141516171819
  1. # Add the first user identity if the local ssh-agent doesn't already have
  2. # something.
  3. #
  4. # We silence error output for when we're sshing to a machine that we don't want
  5. # to use ssh-agent forwarding for.
  6. if [[ `ssh-add -L | grep "^ssh-" | wc -l` -eq 0 ]]; then
  7. ssh-add 2> /dev/null
  8. fi
  9. # Put ssh authentication socket in predicatable place for ssh-agent forwarding.
  10. #
  11. # This allows us to overcome stale sockets in tmux.
  12. SOCK="/tmp/ssh-agent-$USER-tmux"
  13. if test $SSH_AUTH_SOCK && [ $SSH_AUTH_SOCK != $SOCK ]
  14. then
  15. rm -f /tmp/ssh-agent-$USER-tmux
  16. ln -sf $SSH_AUTH_SOCK $SOCK
  17. export SSH_AUTH_SOCK=$SOCK
  18. fi