LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Retaining Bash history from all sessions (https://www.linuxquestions.org/questions/programming-9/retaining-bash-history-from-all-sessions-603218/)

humbletech99 11-29-2007 06:03 AM

Retaining Bash history from all sessions
 
I've noticed that when I have many sessions open, the history from one closed session will overwrite the history from another earlier closed session so that when I open a new session I only see the history of the most recently closed session.

Is there a way I can merge/retain all Bash history from all sessions?

I was thinking about something in the .bash_logout, perhaps a func to merge the histories, appending only the new lines to the history file, but the problem is that the history numbering overlaps, so this could be tricky.

Another question would be how Bash handles the history, is it before or after the processing of the history file? If it's after, then would bash just overwrite the history file with the current session history regardless of what is in .bash_logout?

Any Ideas?

aus9 11-29-2007 07:39 AM

http://www.ducea.com/2006/05/15/linu...-bash_history/

note that I am a fan of having zero history on reboot I touch a new file to stop intruders reading certain things

humbletech99 11-29-2007 08:16 AM

yes I tried this no history for a while too but the inconvenience outweighs the small security I think.

thanks for the link, looked too basic to start, but they mention history -a which I have found elsewhere as a possible solution...

aus9 11-29-2007 04:22 PM

open a shell command
info bash

has more juicy stuff

Tinkster 11-29-2007 05:38 PM

Here's the history relevant part from my ~/.bashrc
Code:

# handle history file gracefully for multiple windows open
shopt -s histappend
export PROMPT_COMMAND='history -a'
# 'normal' history stuff
export HISTFILESIZE=6000
export HISTSIZE=2000
export HISTTIMEFORMAT="%F %T "
export HISTCONTROL=ignoreboth
# and things I don't want to see in my history (ever)
export HISTIGNORE="*PROMPT*:lsc:cd:cd ..:pwd:exit:mc:clear:history *:cd \"\`echo *:ps -A:top:./configure --help:locate:fj"



Cheers,
Tink


All times are GMT -5. The time now is 07:03 PM.