joouha / euporie

Jupyter notebooks in the terminal
https://euporie.readthedocs.io
MIT License
1.54k stars 36 forks source link

Refresh notebook #41

Closed ghost closed 1 year ago

ghost commented 1 year ago

Would it be possible to implement (1) a menu entry that refresh the notebook (i.e. reload it from file) and (2) a feature that continuously monitor the notebook file for changes, and if there are changes, automatically reload it?

The use case is: I edit the notebook in plain vim with the percentage format, and then convert it back to notebook format with jupytext.

I know euporie has vim keybindings, but I have a whole ecosystem in vim which goes beyond keybindings (custom keybindings, plugins, etc.), so I would like to edit the notebook in plain vim, and update it with jupytext.

It would be great if euporie could refresh the notebook automatically.

joouha commented 1 year ago

Hi,

The first item (a command to reload the notebook file) should be pretty easy to implement. I'll try add this to the next release. Euporie's command system means you'll be able to add a custom key-binding for this too.

The continuous file monitoring could be a bit more complex, but it looks like watchdog might work well for this.

ghost commented 1 year ago

oh, thanks!

joouha commented 1 year ago

I've implemented part one of your feature request in the dev branch (here 27a4ac2dfb53443d354e0148191c0b6c05bc937b), so there is now a command called reset-tab, which causes the current notebook to be refreshed from the file-system. The default key-binding for this will be F5, but this will be configurable as explained here.

I'll make sure this is included in the next release.

joouha commented 1 year ago

I've released v2.1.3, which contains the reset-tab command.

ghost commented 1 year ago

It doesn't work :(

see the video: https://www.youtube.com/watch?v=syYEL69Z98U

ghost commented 1 year ago

please watch it until the end as the first time the cell is hidden and it's not clear it's not working :)

joouha commented 1 year ago

Ah I see, thanks for the video. Please try the fix in v2.1.4

ghost commented 1 year ago

it works!!! it doesn't keep output cells when you refresh. for me that's the intended behavior, I don't know for others. maybe the fact that it doesn't keep output cells when refreshed should be documented. It is so much faster than Jupyter notebook. Now I just have to find the command line to tell kitty to update it, and then I bind it in vim. Thanks a lot!

ghost commented 1 year ago

output