I stumbled upon Ledge today. It brands itself as "runnable markdown notes", basically adding a "run" button to code blocks and displaying their result below the block. Looks like there's a couple of clever ideas behind it (all executions within one note share the same shell etc).
For more details, see ledge.sh and the HN discussion thread.
I often use notes to store some commands that I want to remember later, together with some description of the situation I used them in. So I'd totally like to try what Ledge offers!
My first idea was to simply install Ledge and see if I could just tell Joplin to use it as an external editor. But unfortunately my Ubuntu 22.04 is a bit dated, and Ledge was compiled against a newer glibc. Anybody else who is also interested and wants to give this a try? Or are there plugins that I missed that already offer this?
[Posting in features since that seems like the logical place to me, feel free to move!]
Neat idea, and I keep commands in my notes the same way, so I looked into it.
On your question about existing plugins: as far as I can tell, nothing in the catalogue runs shell blocks. The closest is Jopyter Notebook, which runs Python blocks only through a Jupyter kernel. Codeblock Utils and the copy-button plugins don't execute anything.
I also thought about how hard it would be to build as a plugin. A basic version (run the block under the cursor, show the output below it) looks doable on desktop. But three things make a proper Ledge-like experience difficult:
- Mobile. Plugins on mobile run in a sandbox and can't start processes, so the feature would be desktop-only. Ledge gets around this with its own server that the phone connects to, which is a different kind of project than a plugin.
- A real terminal. Anything interactive (a
sudo password prompt, htop, progress bars) needs a pseudo-terminal. The usual library for that is a native module, which has to match Joplin's Electron build on every platform, so it is hard to ship reliably inside a plugin. Without it you only get plain line-by-line output.
- Harmful commands. Notes arrive from many places: sync, shared notebooks, the web clipper, imports, AI tools. Any of them could carry a block that is one keypress away from running on your machine. A plugin like this would need to never auto-run, ask for confirmation, and still relies on the user reading every block before running it.
A very nice idea, but more than a weekend plugin once you go past the basic case.