24 lines
795 B
Bash
24 lines
795 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/tty* ]] && [[ -n "$SSH_AGENT_PID" ]] && {
|
|
eval "$(ssh-agent -k >/dev/null 2>&1)" >/dev/null || printf "\\033[1;31;40m%s\\033[0m\\n" "Failed to stop ssh-agent." >&2
|
|
}
|
|
|
|
# Update the ~/.ssh/agents file.
|
|
__read_ssh_agents && __write_ssh_agents
|
|
}
|