diff --git a/bin/agent.sh b/bin/agent.sh new file mode 100755 index 0000000..fee93e6 --- /dev/null +++ b/bin/agent.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# makes sure agent is active and adds keys +if [ -z $SSH_AGENT_SOCK ] ; then + # agent unset + eval $(ssh-agent -s) + if [ "$(ssh-add -l)" = "The agent has no identities." ] ; then + if [ -e ~/.ssh/id_ed25519 ] ; then + ssh-add ~/.ssh/id_ed25519 + else + kill $SSH_AGENT_PID + echo -e "No ed25519 keys found! Killing $SSH_AGENT_PID!" + fi + else + kill $SSH_AGENT_PID + echo "Killing $SSH_AGENT_PID!" + fi +fi + diff --git a/zshrc b/zshrc index a6710db..674f300 100644 --- a/zshrc +++ b/zshrc @@ -134,4 +134,5 @@ export PATH=$PATH:$HOME/.local/bin # ranger alias alias ranger="python3 $HOME/.ranger.py" -#adding ranger to path +# adding agent startup alias +alias agent="source $HOME/.dotfiles/bin/agent.sh"