27 lines
830 B
Bash
27 lines
830 B
Bash
#!/bin/bash - not strictly necessary, but helps nano with syntax highlighting.
|
|
|
|
# Clear the screen/console on logout.
|
|
if (( SHLVL == 1 )); then
|
|
if [[ -x /usr/bin/clear_console ]]; then
|
|
/usr/bin/clear_console -q
|
|
elif [[ -x /usr/bin/clear ]]; then
|
|
/usr/bin/clear
|
|
elif [[ -x /usr/bin/tput ]]; then
|
|
/usr/bin/tput clear
|
|
else
|
|
echo -ne "\e[2J"
|
|
fi
|
|
fi
|
|
|
|
hash ssh-add ssh-agent >/dev/null 2>&1 && {
|
|
# Stop any started ssh-agent as long as the shell level is 1 and we're not on a tty.
|
|
(( SHLVL == 1 )) && [[ "$(tty)" == /dev/pts/* ]] && [[ -n "$SSH_AGENT_PID" ]] && {
|
|
ssh-agent -k
|
|
(( $? != 0 )) && printf "\\033[1;31;40m%s\\033[0;39m\\n" "Failed to stop ssh-agent." >&2
|
|
sleep 5
|
|
unset SSH_AGENT_PID SSH_AUTH_SOCK
|
|
}
|
|
|
|
# Update the ~/.ssh/agents file.
|
|
__read_ssh_agents && __write_ssh_agents
|
|
}
|