Terminal logout script

Issues and / or general discussion relating to Puppy

Moderator: Forum moderators

Post Reply
d-pupp
Posts: 335
Joined: Tue Nov 22, 2022 9:11 pm
Location: Canada
Has thanked: 188 times
Been thanked: 52 times

Terminal logout script

Post by d-pupp »

Hello puppy users

I like to mess around on the command line however I find my history becomes very messy. Full of duplicates entries
I have export HISTCONTROL=ignorespace:erasedups set in .bashrc however I still end up with duplicates when I exit as bash appends the history in memory to the .history file.
So I found a tip about fixing this with a bash_logout file
To make this work on an interactive shell I added this to .bashrc to trap EXIT

Code: Select all

trap_exit(){
  . "$HOME/.bash_logout"	
}
trap trap_exit EXIT

MY current .bash_logout file

Code: Select all

history -a && history -c && awk '!a[$0]++' .history > .hist && cp .hist .history

The original used sort -u -o file file instead of awk but I didn't want it to sort it.

My question is what have other done with there .history file? Maybe keeping a set of command in there all the time??

Post Reply

Return to “Users”