I use zsh per directory history [0] as well as this cron job I have set to run hourly:<p><pre><code>    #!&#x2F;bin&#x2F;bash

    cd &#x2F;Users&#x2F;nmjohn&#x2F;.directory_history \
      &amp;&amp; git add . \
      &amp;&amp; git commit -m &quot;Automatic Backup: `date`&quot; \
      &amp;&amp; echo &quot;Files Modified:&quot; \
      &amp;&amp; git log head -1 --name-only --pretty=format:&quot;&quot; | grep &quot;[^\s]&quot; | awk &#x27;{print    &quot;\t\t&quot;$0}&#x27; \
      &amp;&amp; echo &quot;&quot;
</code></pre>
It&#x27;s not bullet-proof, but since I never manually touch the directory it&#x27;s worked without hiccup for the last ~6 months. When trying to remember the syntax to a rarely used function (or even the name itself) or coming up with a gnarly awk&#x2F;sed&#x2F;grep command, it&#x27;s been incredibly helpful to have fairly granular search capability to go back and find them weeks later.<p>Also ctrl+g in a terminal toggles between per directory history and global history which makes context switching easier when switching to a project not touched for a while.<p>[0]: <a href="https:&#x2F;&#x2F;github.com&#x2F;jimhester&#x2F;per-directory-history" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;jimhester&#x2F;per-directory-history</a>