[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: feature request: configurable history timestamps
From: |
Chet Ramey |
Subject: |
Re: feature request: configurable history timestamps |
Date: |
Sat, 17 Dec 2011 13:26:43 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0 |
On 12/11/11 1:13 AM, Alex Shinn wrote:
> I had initially been confused by the HISTTIMEFORMAT
> variable thinking it could be used to change what was
> written to the history file, rather than the output of the
> history command.
>
> Obviously it would have to be a separate variable, but
> the ability to add extra info to the history file would be
> very useful to me. Given the pid and pwd you can
> effectively track sessions, and know where you invoked
> a command in addition to when.
>
> As a simple change, just statically appending the bash
> pid such that the history file looks like:
>
> #1323582935 217
> command
>
> would enable constructing a session and inferring the
> pwd by checking for cd/pushd/popd commands (assuming
> no other aliases or scripts are used to chdir).
One question is whether or not this would be of general interest, since
any user-specified text to append to the timestamp would have to come
after the timestamp and be more-or-less ignored by the history code proper.
(and the timestamp would have to be inserted unconditionally). What's the
use case? Third-party forensics? You can already use HISTFILE to break
out history by session, so this would only be worth it if you insisted on
using a single history file for all shell sessions.
I don't think it would be too tough to make the history code behave as it
does today if there were extra text following the timestamp; strtol(3) is
pretty well-behaved. But is it worth the work?
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/