I've mucked around with the idea of auto-running commands when a sheet opens before.
I don't remember which walls I hit, but saulpw/visidata#1681
got me curious to try the idea of a post-load hook in .visidatarc
again.
The contents of post_load_hook.py
could be dropped directly into a .visidatarc
or kept in its own file and imported from .visidatarc
.
This is just a sample of course, but seems to work for some common cases at least. If I try to bulk load a bunch of sheets and reload all of them simultaneously I do get this traceback which suggests I need to do something smarter:
Traceback (most recent call last): ║
File "/home/aj/.local/pipx/venvs/visidata/lib/python3.11/site-packages/visidata/basesheet.py", line 209, in execCommand ║
vd.cmdlog.afterExecSheet(vd.activeSheet, escaped, err) ║
File "/home/aj/.local/pipx/venvs/visidata/lib/python3.11/site-packages/visidata/macros.py", line 71, in afterExecSheet ║
cmdlog.afterExecSheet.__wrapped__(cmdlog, sheet, escaped, err) ║
File "/home/aj/.local/pipx/venvs/visidata/lib/python3.11/site-packages/visidata/cmdlog.py", line 217, in afterExecSheet ║
if not sheet.cmdlog.rows or vd.isLoggableCommand(vd.activeCommand.longname): ║
^^^^^^^^^^^^^^^^^^^^^^^^^ ║
AttributeError: 'NoneType' object has no attribute 'longname'
But hey, omelettes and eggs and all that...