pimterry/notes

Pass args to Post install script

Closed this issue · 6 comments

Issue Summary

Post Script passes no information to the script. I write my notes in md files and I would like to write a script that uses pandoc to convert the md to pdf files when the vim process completes. However, no information is passed to the post-script to make use of a script.

Technical details:

  • notes version: master (latest commit: [commit number])

Ah, so to be clear you're using the POST_COMMAND configuration to do this?

Yes, right now that's just run without any arguments at all. We could pass arguments here, although it would potentially be difficult to do so (we'd need to recalculate the actual paths of the files touched, which isn't known at the point where this is run - many things are implicit, e.g. with autogenerated quicknote filenames, automatically incldued file extensions, globs, etc).

Note also that the POST_COMMAND is run once, after the entire command finishes - that may be after multiple files are edited, or before editing is completed (if your $EDITOR command doesn't block, which is common for GUI launchers), and it's very possible that any editor you open could be used to manually modify other notes, which notes will always be unaware of. Doing this 'right' 100% of the time may be harder than you'd expect.

Can you explain which arguments you'd like to receive, and more detail about how you'd like this to work?

I think for your use case, you might want to instead either provide a custom $EDITOR which does this implicitly for each individual file, and/or use a script that just filters for files with modified dates more recent that their corresponding pdf output. Would that work?

I understand the issue here. The present architecture does not allow for passing any arguments to the POST_COMMAND script. As you said, the editor may edit other files that your script may not know of.

Would it be able to pass the $NOTESDIRECTORY path to POST_COMMAND script? Since I am on ZSH and the script runs in BASH, I think there are incompatibility regards to environment variables. I may be doing something wrong but I think NOTESDIRECTORY seems like a good improvement.

Would it be able to pass the $NOTESDIRECTORY path to POST_COMMAND script?

I'm cautious, because it's a breaking change, and it's a bit of an arbitrary addition - I can imagine how it might be useful in your case, but there will be plenty of people for whom it's surprising and a little confusing.

How about providing a separate command to print the notes directory? Would that work for your use case? I'm imagining notes realpath (broadly matching coreutils realpath) that would return the absolute path to the notes dir (root by default, or to a specific file/dir if provided e.g. with notes realpath projects/abc).

Then you can just run that in your script, without needing to change the arguments provided. And you could also do the same elsewhere too, separate from POST_COMMAND. I'm sure there'll be other cases where this could come in handy too, seems like a nice addition.

I understand your concern. The alternative sounds wonderful! Thank you so much

Ok, great! To be clear, I'm not going to add this myself, I really don't have much time at the moment, but if you're interested and you open a PR for this then I'd be happy to review it and include that in the project. Let me know if you want any pointers on how that should work or how to do that.