snipt

Ctrl+h for KB shortcuts

Bash

Bash—please save my history for ever and eternity (or, at least a really long time)

1
2
3
4
5
6
# In .bashrc or .bash_profile
export HISTCONTROL=ignoredups:ignorespace
export HISTSIZE=10000
export HISTFILESIZE=1000000
export HISTTIMEFORMAT="%F %T "
export PROMPT_COMMAND='history -a'
https://snipt.net/embed/66a35c6d935778d767cbf849bd50c74f/
/raw/66a35c6d935778d767cbf849bd50c74f/
66a35c6d935778d767cbf849bd50c74f
bash
Bash
7
2019-08-20T20:06:21
True
False
False
/api/public/snipt/6723/
bashsave-my-history-for-ever-and-eternity-well-almost
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1"># In .bashrc or .bash_profile</span> </span><span id="L-2"><a name="L-2"></a><span class="nb">export</span> <span class="nv">HISTCONTROL</span><span class="o">=</span>ignoredups:ignorespace </span><span id="L-3"><a name="L-3"></a><span class="nb">export</span> <span class="nv">HISTSIZE</span><span class="o">=</span>10000 </span><span id="L-4"><a name="L-4"></a><span class="nb">export</span> <span class="nv">HISTFILESIZE</span><span class="o">=</span>1000000 </span><span id="L-5"><a name="L-5"></a><span class="nb">export</span> <span class="nv">HISTTIMEFORMAT</span><span class="o">=</span><span class="s2">&quot;%F %T &quot;</span> </span><span id="L-6"><a name="L-6"></a><span class="nb">export</span> <span class="nv">PROMPT_COMMAND</span><span class="o">=</span><span class="s1">&#39;history -a&#39;</span> </span></pre></div> </td></tr></table>
bash, history