Created
June 2, 2021 21:37
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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