# Starts the ssh-agent if it is not running, and either way it sources the required environment variables. if [ -z "$(ps -e | grep ssh-agent)" ]; then # ssh-agent does not seem to be running, start it ssh-agent | sed -r '/echo Agent pid [0-9]+;/d' > "$HOME/.ssh/session" fi eval $(<"$HOME/.ssh/session")