nbstata icon indicating copy to clipboard operation
nbstata copied to clipboard

Shell Command Magic for Stata Kernel

Open jiboncom opened this issue 4 months ago • 2 comments

It would be helpful to support a shell-style magic command that sends input directly to the system terminal; similar to how the Python kernel uses the !command syntax. My first idea was to use Stata's native shell command, but it doesn't recognize my Jupyter installation. I don't know if others have the same problem..

Use Case: One particularly useful application would be the ability to export a notebook’s Stata code cells to a .do file using nbconvert or a custom script, all from within the notebook itself. An even better addition would be another magic to quickly generate a do file.

jiboncom avatar Jul 23 '25 19:07 jiboncom

Yes, love this idea. We should be able to do it in the same way as IPythonKernel does, though that's easier said than done (for me).

hugetim avatar Jul 24 '25 04:07 hugetim

I am curious, why is that? I might be wrong, but I assume that getting the !command is the easy part.

The PyStataKernel inherits from IPythonKernel, that means it has all the logic of execute_request() from ipykernel/ipykernel/kernelbase.py and do_execute() from ipykernel/ipykernel/ipkernel.py.

Can't it just do that?

jiboncom avatar Jul 29 '25 00:07 jiboncom