diff --git a/.bash_logout b/.bash_logout index 6c254ae..7bc70d4 100644 --- a/.bash_logout +++ b/.bash_logout @@ -13,9 +13,9 @@ if (( $SHLVL == 10 )); then fi fi -# Remove the SSH_AUTH_SOCK from the agents file. -(( $SHLVL == 1 )) && { - hash ssh-add ssh-agent >/dev/null 2>&1 && [[ ! -z "$SSH_AGENT_PID" ]] && [[ ! -z "$SSH_AUTH_SOCK" ]] && { +hash ssh-add ssh-agent >/dev/null 2>&1 && { + # Remove the SSH_AUTH_SOCK from the agents file. + [[ ! -z "$SSH_AUTH_SOCK" ]] && { exec 9>~/.ssh/agents.lock if flock -E 10 -w 0.5 9; then _pop_agent_sock || { @@ -27,10 +27,16 @@ fi _SLEEP=3 fi exec 9>&- - ssh-agent -k >/dev/null 2>&1 || { - echo -e "$(tput setaf 1 || tput AF 1)Failed to kill ssh-agent!$(tput op)" - _SLEEP=3 + } + + # Kill the ssh-agent. + (( $SHLVL == 1 )) && { + [[ ! -z "$SSH_AGENT_PID" ]] && { + ssh-agent -k >/dev/null 2>&1 || { + echo -e "$(tput setaf 1 || tput AF 1)Failed to kill ssh-agent!$(tput op)" + _SLEEP=3 + } } - sleep ${_SLEEP:-0} } } +sleep ${_SLEEP:-0}