macOS Sierra ssh-agent autoload keys

For some reasons, loading my ssh identities to ssh-agent no longer worked, when upgrading OS X El Capitan to macOS Sierra. I played around and found the following working solution for me.

As I use Homebrew and the bash provided by this project, I have added the following code snippet to my users .bashrc file:

if [[ -n "$SSH_AUTH_SOCK" ]]; then
    ssh-add -l >/dev/null 2>&1
    if [[ "$?" -eq 1 ]]; then
    	ssh-add -A
    fi
fi

.bashrc is a symlink on my machine, which points to .bash_profile.