Skip to content

Instantly share code, notes, and snippets.

@atomicstack
Created June 2, 2021 21:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atomicstack/9e8a1efcdbb82fd56b0eab8d3c56c47f to your computer and use it in GitHub Desktop.
Save atomicstack/9e8a1efcdbb82fd56b0eab8d3c56c47f to your computer and use it in GitHub Desktop.
a zsh thing to run at login time and check whether the user has an ssh-agent
red=$(tput setaf 1)
reset=$(tput sgr0)
if [[ -n "${SSH_TTY}" || -n "${TTY}" ]]; then
if [[ $UID == 0 ]]; then
return
fi
if [[ -z "$SSH_AUTH_SOCK" || ! -S "$SSH_AUTH_SOCK" ]]; then
echo -e "${red}no ssh-agent found :(${reset}"
elif ssh-add -l | grep -q "no identities"; then
echo -e "${red}no ssh keys loaded${reset}"
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment