aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/%HOME%/.profile
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2018-06-04 23:30:25 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2018-06-04 23:30:25 +0300
commitdc5914816bf4d8afbeccc4fae3f77dff304187b9 (patch)
treed33fa11cd233f27ae78fe55c20eb51abb6f41c42 /%HOME%/.profile
parent.bashrc: don't source missing files (diff)
downloadlinux-home-dc5914816bf4d8afbeccc4fae3f77dff304187b9.tar.gz
linux-home-dc5914816bf4d8afbeccc4fae3f77dff304187b9.zip
ssh.sh: move to .profile
Diffstat (limited to '')
-rw-r--r--%HOME%/.profile18
1 files changed, 18 insertions, 0 deletions
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