ssh-agent.plugin.zsh 503 B

1234567891011121314151617181920212223
  1. # Based on code from Joseph M. Reagle
  2. # http://www.cygwin.com/ml/cygwin/2001-06/msg00537.html
  3. local SSH_ENV=$HOME/.ssh/environment-$HOST
  4. function start_agent {
  5. /usr/bin/env ssh-agent | sed 's/^echo/#echo/' > ${SSH_ENV}
  6. chmod 600 ${SSH_ENV}
  7. . ${SSH_ENV} > /dev/null
  8. /usr/bin/ssh-add;
  9. }
  10. # Source SSH settings, if applicable
  11. if [ -f "${SSH_ENV}" ]; then
  12. . ${SSH_ENV} > /dev/null
  13. ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
  14. start_agent;
  15. }
  16. else
  17. start_agent;
  18. fi