[kwlug-disc] bash: HISTTIMEFORMAT
CrankyOldBugger
crankyoldbugger at gmail.com
Wed Mar 4 15:22:16 EST 2026
Here you go:
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth:erasedups
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=9999
HISTFILESIZE=9999
HISTTIMEFORMAT="%y/%m/%d %T "
This should give me a very large history file, but duplicates will be
removed (i.e. if I type 'ls' four times in a row, only one 'ls' will be
saved to the history file)
People have argued that I should have gone with a four digit year format,
but I am a veteran of the Y2K Wars and can do whatever I want!
On Wed, 4 Mar 2026 at 20:09, Alex Kleider via kwlug-disc <
kwlug-disc at kwlug.org> wrote:
> Would you be willing to share the relevant parts of your .bashrc/
> a
>
> Alex Kleider (set from my current gizmo)
>
> On Wednesday, March 4th, 2026 at 9:29 AM, CrankyOldBugger <
> crankyoldbugger at gmail.com> wrote:
>
> I added to my .bashrc, where I have other history options set, changed the
> date format to something more Canadian, and it looks like this now:
>
> 8928 26/03/04 12:24:48 history
>
> So that's an improvement over not having the date..
>
>
> On Wed, 4 Mar 2026 at 16:52, Jason Eckert <jason.eckert at gmail.com> wrote:
>
>> That option doesn't work in bash's history built-in function. You'd have
>> to use zsh instead.
>>
>> On Wed, 4 Mar 2026 at 11:37, Alex Kleider via kwlug-disc <
>> kwlug-disc at kwlug.org> wrote:
>>
>>> Doesn't seem to work on my Debian XFCE system (a release or two ago.)
>>> $ history -i
>>> bash: history: -i: invalid option
>>> history: usage: history [-c] [-d offset] [n] or history -anrw [filename]
>>> or history -ps arg [arg...]
>>>
>>> Alex Kleider (set from my current gizmo)
>>>
>>> On Wednesday, March 4th, 2026 at 6:02 AM, Jason Eckert <
>>> jason.eckert at gmail.com> wrote:
>>>
>>> Like Raymond, the 'history -i' command has been my go-to for ages.
>>> I switched to zsh long ago for aesthetic consistency... it matches zfs,
>>> zswap, etc… I’m nothing if not alphabetically aligned.
>>>
>>> On Wed, 4 Mar 2026 at 08:52, Raymond Chen <raymondchen625 at gmail.com>
>>> wrote:
>>>
>>>> Very nice! BTW, in zsh it's `history -i`.
>>>>
>>>> On Wed, Mar 4, 2026 at 8:37 AM CrankyOldBugger <
>>>> crankyoldbugger at gmail.com> wrote:
>>>>
>>>>> Nice one!
>>>>>
>>>>> On Wed, 4 Mar 2026 at 03:11, Chris Frey <cdfrey at foursquare.net> wrote:
>>>>>
>>>>>> It turns out that by setting the environment variable HISTTIMEFORMAT
>>>>>> on startup to something like "%Y-%m-%dT%T " bash will both display
>>>>>> the timestamp of all commands when you use the 'history' command,
>>>>>> but also store the timestamps in the .bash_history file.
>>>>>>
>>>>>> Now I have an automatic trail of timed breadcrumbs in case I need it,
>>>>>> for all my shell work.
>>>>>>
>>>>>> Just passing along the tip.
>>>>>>
>>>>>> - Chris
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> kwlug-disc mailing list
>>>>>> To unsubscribe, send an email to kwlug-disc-leave at kwlug.org
>>>>>> with the subject "unsubscribe", or email
>>>>>> kwlug-disc-owner at kwlug.org to contact a human being.
>>>>>>
>>>>> _______________________________________________
>>>>> kwlug-disc mailing list
>>>>> To unsubscribe, send an email to kwlug-disc-leave at kwlug.org
>>>>> with the subject "unsubscribe", or email
>>>>> kwlug-disc-owner at kwlug.org to contact a human being.
>>>>>
>>>> _______________________________________________
>>>> kwlug-disc mailing list
>>>> To unsubscribe, send an email to kwlug-disc-leave at kwlug.org
>>>> with the subject "unsubscribe", or email
>>>> kwlug-disc-owner at kwlug.org to contact a human being.
>>>>
>>>
>>> _______________________________________________
>>> kwlug-disc mailing list
>>> To unsubscribe, send an email to kwlug-disc-leave at kwlug.org
>>> with the subject "unsubscribe", or email
>>> kwlug-disc-owner at kwlug.org to contact a human being.
>>>
>> _______________________________________________
>> kwlug-disc mailing list
>> To unsubscribe, send an email to kwlug-disc-leave at kwlug.org
>> with the subject "unsubscribe", or email
>> kwlug-disc-owner at kwlug.org to contact a human being.
>>
>
> _______________________________________________
> kwlug-disc mailing list
> To unsubscribe, send an email to kwlug-disc-leave at kwlug.org
> with the subject "unsubscribe", or email
> kwlug-disc-owner at kwlug.org to contact a human being.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kwlug.org/pipermail/kwlug-disc_kwlug.org/attachments/20260304/b796939f/attachment-0001.htm>
More information about the kwlug-disc
mailing list