The script above marked as .bashrc will start a ssh-agent
the first time
a bash shell is launched. It records the agent's environmental variables in
a file at ~/.ssh/environment
. Whenever a subsequent shell is launched,
it will first attempt to read ~/.ssh/environment
and use the same agent,
if the environment file exists and the process is alive.
When shells are closed by exiting, kill_ssh_agent
runs automatically. It
detects whether more bash processes are open, and will only kill the agent
and delete the file if the current process is the last real shell. If
another bash shell is still open, the agent stays alive.