5 ms·
I use zsh per directory history [0] as well as this cron job I have set to run hourly: #!/bin/bash cd /Users/nmjohn/.directory_history \ && git
by nmjohn 11y ago
I use zsh per directory history [0] as well as this cron job I have set to run hourly:
#!/bin/bash
cd /Users/nmjohn/.directory_history \
&& git add . \
&& git commit -m "Automatic Backup: `date`" \
&& echo "Files Modified:" \
&& git log head -1 --name-only --pretty=format:"" | grep "[^\s]" | awk '{print "\t\t"$0}' \
&& echo ""
It's not bullet-proof, but since I never manually touch the directory it'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/sed/grep command, it's been incredibly helpful to have fairly granular search capability to go back and find them weeks later.
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.
[0]: https://github.com/jimhester/per-directory-history https://github.com/jimhester/per-directory-history
- thebelal 11y agoGreat to hear you find per-directory-history useful! (I wrote it) On the topic of the article I have per directory history going back to ~2013 when I wrote the script.