<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div style="word-wrap:break-word"><div><div><div>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.<br>
</div></div></div></div></blockquote><div><br></div><div>Yes, put this in your .bashrc:</div><div><br></div><div><div>PROMPT_COMMAND="${PROMPT_COMMAND:-:} ; history -a; history -n"</div></div><div><br></div><div>
At every prompt it will append to the history file commands run since the last time it was appended.</div><div><br></div><div>The second, history -n, is optional... it will reread the history file.</div><div><br></div><div>
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.</div><div><br>
</div><div>Also, you might find histappend needs set (put this also in your .bashrc):</div><div><br></div><div>shopt -s histappend</div><div><br></div><div>-Eric</div><div><br></div></div></div></div>