PeterVandivier
I like to [keep a lot of `.bash_history`](https://stackoverflow.com/a/19454838/4709762). Sometimes though - when I want to browse my history, I'd rather take a look around a known point in time rather than searching for a text match.
Is there a configuration I can try that might help me with this? So far the only idea I've had is to add the following to my `.bash_logout`...
```bash
echo "#################################" >> ~/.bash_history
echo "# LOGOUT $(date +%Y%m%dT%H%M%S%z)" >> ~/.bash_history
echo "#################################" >> ~/.bash_history
```
Can I do better?
Top Answer
Jack Douglas
I think [`HISTTIMEFORMAT`](https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html#index-HISTTIMEFORMAT) is what you are looking for
> If this variable is set and not null, its value is used as a format string for *strftime* to print the time stamp associated with each history entry displayed by the `history` builtin. If this variable is set, time stamps are written to the history file so they may be preserved across shell sessions. This uses the history comment character to distinguish timestamps from other history lines.
~~~ shell
$ export HISTTIMEFORMAT='%F %T '
$ echo 'Hi Peter'
~~~
~~~none
Hi Peter
~~~
~~~ shell
$ history | tail -n3
~~~
~~~none
721 2020-10-18 14:38:15 export HISTTIMEFORMAT='%F %T '
722 2020-10-18 14:38:17 echo 'Hi Peter'
723 2020-10-18 14:38:21 history | tail -n3
~~~