about summary refs log tree commit diff stats
path: root/.bash_logout
diff options
context:
space:
mode:
authorDavid Morgan <david.morgan@gmail.com>2016-04-29 12:33:37 +0100
committerDavid Morgan <david.morgan@gmail.com>2016-04-29 12:33:37 +0100
commit8cb37160d7b26eab19b287a9f5ee84ad37e3b53a (patch)
treec3eba59149c6acf499a5f8f1ff8d98d04a8268d3 /.bash_logout
parent31d7ea2ab52e88ccb850ec8b9397b04e248731fe (diff)
downloaddotfiles-8cb37160d7b26eab19b287a9f5ee84ad37e3b53a.tar.gz
Add .bash_logout, plus .bashrc tweaks
Diffstat (limited to '.bash_logout')
-rw-r--r--.bash_logout13
1 files changed, 13 insertions, 0 deletions
diff --git a/.bash_logout b/.bash_logout
new file mode 100644
index 0000000..df7ab07
--- /dev/null
+++ b/.bash_logout
@@ -0,0 +1,13 @@
+# don't leave behind any stray ssh sessions - kill them when bash exits,
+# unless it was running inside a tmux session (but the idea is to kill
+# ssh sessions running inside tmux!)
+if [ -n "${SSH_CONNECTION}" -a -z "${TMUX}" ]; then
+    for ssh_host in $(grep 'Host\b' .ssh/config|cut -f2 -d' ') ; do
+        ssh_pid=$(ps u|awk "/ssh ${ssh_host}/ && !/grep/{print $2}")
+        [ -n "${ssh_pid}" ] && kill ${ssh_pid} 2>/dev/null
+    done
+fi
+
+if [ "$SHLVL" = 1 ]; then
+    [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
+fi