[colug-432] Search Command History

Eric Floehr eric at intellovations.com
Tue Feb 11 08:59:33 EST 2014


>
> Is there something I'm missing that will cause this to get written more
> immediately than on a proper logout?  I've run into several situations
> where I really needed to see that history to know what someone else was
> doing, or where I left off, or what that complex sed command was - but I'm
> out of luck.
>

Yes, put this in your .bashrc:

PROMPT_COMMAND="${PROMPT_COMMAND:-:} ; history -a; history -n"

At every prompt it will append to the history file commands run since the
last time it was appended.

The second, history -n, is optional... it will reread the history file.

Note that multiple shells will have their history intermingled, so you do
run into a few problems up-arrowing and not always seeing a coherent past.
I've removed history -n for that reason on my shells.

Also, you might find histappend needs set (put this also in your .bashrc):

shopt -s histappend

-Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.colug.net/pipermail/colug-432/attachments/20140211/0f1ce490/attachment.html 


More information about the colug-432 mailing list