]> arthur.barton.de Git - ConfigScripts.git/blobdiff - user/bash_logout
Better debug logging, display when script really starts
[ConfigScripts.git] / user / bash_logout
index 59a12fcda4db48a8316fae73fb4bf3fa7d37855f..8265c8d4370f16217105c69c9429921fab2d1d28 100644 (file)
@@ -1,24 +1,35 @@
 #
-# ~/.bash_logout
+# ~/.bash_logout: executed by bash(1) on logout
+# Written 2003-2014 by Alexander Barton (alex@barton.de)
 #
-# 2008-08-07, alex@barton.de
-#  - Show message of "ssh-agent -k"
-#  - Clear screen if last shell on local console.
-# 2003-07-13, alex@barton.de
-#  - Initial version.
+# This script is executed by bash(1) on logout.
 #
+# PLEASE NOTE:
+# To make this script generic, it sources ~/bash_logout.user if it exists.
+# So you shouldn't make changes to this script, but create your own
+# individual ~/bash_logout.user file!
+#
+
+[ -e ~/.ConfigScripts.debug ] && echo " .. ~/.bash_logout ..."
+
+[ -r ~/.bash_logout.user ] && source ~/.bash_logout.user
 
-[ -e /tmp/ConfigDebug.$USER ] && echo " >> ~/.bash_logout ..."
+[ -e ~/.ConfigScripts.debug ] && echo " >> ~/.bash_logout ..."
 
-# clean up SSH agents
-[ $SSH_AGENT_PID ] && eval `ssh-agent -k`
+# Clean up SSH agents, if running and not using keychain(1)
+if [ $SSH_AGENT_PID ]; then
+       type -t keychain >/dev/null || eval `ssh-agent -k`
+fi
 
+# Clear the console if it is a local terminal
 case `tty` in
-/dev/tty[0-9]*)
+    /dev/tty[0-9]*|/dev/ttyS[0-9]*)
        [ -x /usr/bin/clear_console ] && /usr/bin/clear_console --quiet || clear
        ;;
-*)
-       echo "Bye, bye, $USER!"; echo
+    *)
+       if [ -z "$SUDO_USER" ]; then
+               echo "Bye, bye, $LOGNAME!"; echo
+       fi
 esac
 
 # -eof-