#!/bin/sh # This script loads ssh-agent and shares the instance across multiple instances # of rxvt. # # Written and released under GPL by Joseph Reagle, found here: # http://www.cygwin.com/ml/cygwin/2001-06/msg00537.html # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . SSH_ENV="$HOME/.ssh/environment" function start_agent { ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}" chmod 600 "${SSH_ENV}" . "${SSH_ENV}" > /dev/null ssh-add; } if [ -d "$HOME/.ssh" ]; then if [ -f "${SSH_ENV}" ]; then . "${SSH_ENV}" > /dev/null ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || { start_agent; } else start_agent; fi fi