Explain why .bash_logout won't run commands?
Posted
by
Droogans
on Super User
See other posts from Super User
or by Droogans
Published on 2012-04-09T22:06:20Z
Indexed on
2012/04/09
23:36 UTC
Read the original article
Hit count: 191
So I've been wondering how to run these two lines of code everytime I close an open instance of Terminal:
history -c
cat /dev/null > ~/.bash_history
I export HISTFILE=5
on startup, but still want to flush that out when I'm done.
I've tried looking around a bit in a couple of places, and haven't had much luck.
I run Linux Mint, and would also note here that I ran into a similar issue with .bash_profile
; eventually, I discovered I needed to place all start up code in .bashrc
, so maybe that has something to do with it. Here's my .bash_logout
file:
#!/bin/bash
# ~/.bash_logout: executed by bash(1) when login shell exits.
# when leaving the console clear the screen to increase privacy
if [ "$SHLVL" = 1 ]; then
history -c
cat /dev/null > ~/.bash_history
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi
#this does nothing on exit...
echo 'logout'; sleep 2s
I've tried re-arranging this script many ways, I'm not sure if I don't understand how bash works, and if any of this is running in the first place. Does the fact that I run Xserver
make bash consider Terminal something that isn't a log-out on exit?
© Super User or respective owner