capturing bash history
the hatter
london.pm at bang.meep.org
Wed Jun 13 10:17:22 BST 2007
On Wed, 13 Jun 2007, Aaron Crane wrote:
> the hatter writes:
> > On Tue, 12 Jun 2007, Nigel Hamilton wrote:
> > > 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.
> >
> > Isn't bash 3 supposed to do that properly out of the box ?
>
> Not according to its manual or its NEWS file. If you have a reference, I'm
> definitely interested.
My hazy memory isn't directly accessable like that. In my defence,
http://www.ducea.com/2006/05/15/linux-tips-take-control-of-your-bash_history/
has many relevant things. Most succinctly:
You know you can just tell bash to append rather than overwrite the
history file on exit, right?
shopt -s histappend
Which I guess is a common default but not on some linux distribs, because
I've heard other people complain that they only get one session in their
history, but I've never run across it (I've used a range of unices with
bash, but tend not to use the popular linux ones).
> > IIRC correctly, it also does something timestampy with the logs, so you
> > could likely merge them if you rsunc them or similar.
>
> The timestampy thing is enabled by the HISTTIMEFORMAT variable. That does
> sound like it would help with merging.
I was thinking across servers, but if my hazy memory proves something less
than 100% reliable, then you could also set the history file per-session
in your bashrc to something like ~/bash/history.$PID and merge them
semi-regularly (or some some sort of $DATE and use $DATE.$PID for rather
more robustness, or just ++ an index number somehow)
the hatter
More information about the london.pm
mailing list