capturing bash history asmith9983 at
Thu Jun 14 08:23:43 BST 2007

Hi Aaron
I hadn't read your reply to this until I got home.  I sometimes get annoyed 
with bash only updating .bash_history when it exits properly. Also no date 
against the command.
1. What do you think of an idea to amend the history logging to use the syslog 
facility, which would record  as it executes each command line.  An extension 
would be to set an environment variable to allow the user to identify the 
2. As above but still writing to .bash_history, but flushing after each line 
so that  system resets, and window closes  don;t lose the history log.

I've still to read the URL you posted below on power_tips. I tend to always 
use the fc command rather than history.  The only time I generally fiddle with 
.bash_history is to redirect :> .bash_history to hide what I've been up to!


On Tue, 12 Jun 2007, Aaron Crane wrote:

> Nigel Hamilton writes:
>> I'd like to keep a history of all shell commands across all the xterms I'm
>> using but the ~/.bash_history only holds history from one terminal.  Any
>> ideas on interleaving the shell history from multiple terminals into one
>> file?
> This is the magic:
>  # Append to the history file on shell exit, don't overwrite (so multiple
>  # exiting shells don't race to scribble over your saved history)
>  shopt -s histappend
>  # Keep lots of history around
>  export HISTSIZE=1000000 HISTFILESIZE=1000000
>  # Store history in a different file, so it won't get overwritten if you
>  # don't have these settings
>  export HISTFILE=~/.bash_history_safe
>  # Write unsaved history immediately before emitting each prompt
>  export PROMPT_COMMAND='history -a'
> I stole most of that from Smylers:
>> p.s. it would be great if I could get this to work across multiple machines
>> too --- but I'll settle for one machine to start with
> I've never wanted that, but it's essentially going to be a matter of copying
> history files from place to place, and appending their deduped contents to
> the desired history file on each machine.  I suspect the trickiest bit is
> working out when to do it; on each prompt sounds painfully slow, for example.

More information about the mailing list