I found the following snip of code useful to automatically run keychain every time a shell is spawned, and so I though I'd share it.

Instead of just blindly running the keychain program (which caused a perceptible lag when starting up konsole for me), it checks if keychain has already created its files and if so, sources it. Afterwards it checks (through ps) if there's actually an ssh-agent running with the pid from the keychain file. If not, keychain is re-run and its file re-sourced.

Just put the following code somewhere in your .bashrc and replace <key-file> with the filename of your private key.