-
-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Allow defining automatic actions when opening a sheet #1681
Comments
Something like #1488 ? |
Thanks for that thread. I copied some of the code from here into a command and now I have one command which I can launch to config all my columns the way I like them. Now what's missing for me is a hook that'll automatically launch this command whenever a sheet is opened... Right now I just launch it with a key binding, which is an 80% solution. |
It might be possible to use vd.sync() to wait for the loading to finish. I'm not sure if this is an async thread or not. @cool-RR, please share if you get this to work. This would be very useful. |
Thanks, but I've lost interest in getting it to work for now, I think I'll just use my key binding every time I open a sheet. |
@saulpw any suggestions for how Visidata could call a function after loading a sheet, so that customization could be performed like setting column types. I would also be very interested in this. |
One thing you could try that should work for any sheet type which uses iterload, is this (for JsonSheet in this case):
It would have to be done separately for each specific sheet type, which may or may not be a problem for what you want to do. I hear y'all though, and I'll give some thought to how we can do this. There are some places internally that could use this too. |
I haven't tried this suggestion of the before and after decorators. I plan to. This was in the changelog but I didn't see it. Does this work for DirSheet?
I have also asked to hide the "directory" column on the DirSheet when there is only one value. I like seeing similar interests: |
@saulpw I now tried the method you suggested, but it doesn't work. The code does get invoked, but it appears that the data needed to perform autotune (columns and rows?) isn't ready on the sheet yet, so autotune doesn't work properly. |
This is a neat idea, and was making my brain itch because I'm pretty darn sure I remember talking through possibilities with folks in the past (it would have been folks already in this thread for sure). In any case this issue motivated me to see if a generic post-load hook would be doable purely from Sample fumblings up here which I certainly wouldn't trust to handle payroll but might be fun to play with. If nothing else my sheets seem to be auto-resizing on load now, which (similar to @cool-RR) is typically the first thing I do when opening a sheet anyway. |
@ajkerrigan Thank you. I tried it now and it works for some cases, not for others. When I use VisiData to browse a folder and press Enter to load a subfolder, it doesn't work. But even in this state it's very useful to me. Thank you! |
Ah cool, I figured there would be some fun edge cases! I see that same behavior on my end when browsing subfolders. Looks like when the resize fires in that case, |
Okay, these both work now, and are the officially endorsed way of accomplishing the goal of running some code or executing some command after the sheet has finished loading:
Hopefully these are sufficient tools to configure VisiData to do whatever you might want in your .visidatarc! |
I'm happy to hear that. I tried it now though and it didn't work. Not even when I did this:
Am I doing something wrong? The commit I have installed is |
I think you need to decorate the sheet.afterLoad function. Like:
I haven't tried it, I could be mistaken! |
@geekscrapy I don't understand at all. When you say "you need to decorate the |
@geekscrapy is right, though said properly, in order to decorate the Sheet.afterLoad function, you need to name your function
where the |
Works, thank you. For some reason though I couldn't get |
This does not seem to work as I would expect using the examples from above #1681 (comment). it looks like Visidata gets stuck on a macro sheet. And with the DirSheet, I would like to be able to do an undo, as my first to unhide only the I try a demo, where
https://asciinema.org/a/Tgfk13C70oFb6OYIL3jFq3xiA
|
Okay, thanks @frosencrantz. I don't know exactly what's happening, but I can tell the after- |
Whenever I open a sheet, I want VisiData to do some things automatically for me. This is stuff that I find myself doing manually every time, and it's tedious. For example:
g_
).I want these things to happen even if I'm opening a derived sheet in VisiData.
Basically I want to define a set of rules that check what kind of sheet I just opened, and based on that, do a list of pre-defined actions automatically.
The text was updated successfully, but these errors were encountered: