Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save milescsmith/51e90e561c5bc7c8f4fae73dbcc6a1d3 to your computer and use it in GitHub Desktop.

Select an option

Save milescsmith/51e90e561c5bc7c8f4fae73dbcc6a1d3 to your computer and use it in GitHub Desktop.
Auto-start ssh-agent in ZSH
Auto-start ssh-agent in ZSH
#tips#wsl#zsh#ssh-agent
To auto-start the ssh-agent when using zsh add this snippet to your ~/.zshrc:
if [ $(ps ax | grep "[s]sh-agent" | wc -l) -eq 0 ] ; then
eval $(ssh-agent -s) > /dev/null
if [ "$(ssh-add -l)" = "The agent has no identities." ] ; then
# Auto-add ssh keys to your ssh agent
# Example:
# ssh-add ~/.ssh/id_rsa > /dev/null 2>&1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment