janpfeifer / gonb

GoNB, a Go Notebook Kernel for Jupyter
https://github.com/janpfeifer/gonb
MIT License
467 stars 32 forks source link

support %%shell in GoNB runtime #102

Closed m-rit closed 3 months ago

m-rit commented 3 months ago

currentlt %%shell return the error - "%%shell" unknown or not implemented yet. This enhancement can allow bash commands to be executed in one process.

janpfeifer commented 3 months ago

hi @m-rit

Have you tried the ! and !* special operators ? They are shell executing. Examples:

!ls
!ii=0; while ((ii < 10)) ; do echo $ii ; ((ii+=1)) ; done

The difference is that ! executes on the path where the kernel (and JupyterLab) were executed (in my case usually ${HOME}). And !* executes in the temporary directory where the Go code from the cells are saved, and it's a convenience to executes commands like go mod or go work if you want to change behavior on how GoNB compiles the program.

See more examples and description using %help special command.

janpfeifer commented 3 months ago

Or did you mean %shell as something that would make the whole cell to be interpreted as a shell script ?

janpfeifer commented 3 months ago

Half-way implemented, to appear in the next release, hopefully this weekend.

janpfeifer commented 3 months ago

hi @m-rit , I think this is officially in with the v0.10.0 release.

I'll mark it as closed, but if you find any issues, feel free to reopen it.