From dc5914816bf4d8afbeccc4fae3f77dff304187b9 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 4 Jun 2018 23:30:25 +0300 Subject: ssh.sh: move to .profile --- %HOME%/.profile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to '%HOME%/.profile') diff --git a/%HOME%/.profile b/%HOME%/.profile index 401947b..b1e7153 100644 --- a/%HOME%/.profile +++ b/%HOME%/.profile @@ -59,3 +59,21 @@ python_setup() { python_setup python3 python [ -r "$HOME/.pythonrc" ] && export PYTHONSTARTUP="$HOME/.pythonrc" + +# ssh-agent + +kill_ssh_agent() { + [ -n "${SSH_AGENT_PID:+x}" ] && kill "$SSH_AGENT_PID" +} + +spawn_ssh_agent() { + local output + [ -z "${SSH_AGENT_PID:+x}" ] \ + && command -v ssh-agent > /dev/null 2>&1 \ + && output="$( ssh-agent -s )" \ + && eval "$output" > /dev/null \ + && [ -n "${SSH_AGENT_PID:+x}" ] \ + && trap kill_ssh_agent EXIT +} + +spawn_ssh_agent -- cgit v1.2.3