Skip to content
This repository has been archived by the owner on Dec 2, 2021. It is now read-only.

Automatically update Jupyter on save? #4

Open
josswright opened this issue Feb 28, 2018 · 7 comments
Open

Automatically update Jupyter on save? #4

josswright opened this issue Feb 28, 2018 · 7 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@josswright
Copy link

Is there any way to have the Jupyter notebook refresh automatically on save? Or even manually via a command?

(Just to add: this is an amazing plugin -- thank you! I've been interacting with Jupyter notebooks more and more in my data analysis work, and had been desperately hoping that someone would make something like this!)

@szymonmaszke szymonmaszke added the enhancement New feature or request label Feb 28, 2018
@szymonmaszke
Copy link
Owner

You can refresh the web page to see the new content. I've been looking into the ways of automatic refreshing (using xdotool for example) but it seems close to impossible to find tab with Jupyter notebook in your browser. I probably could refresh it ONLY IF last used tab is the notebook, otherwise I think it is a dead end.

Maybe it would be possible using Jupyter's Python API, adding it as an enhancement, no promises though.

@szymonmaszke
Copy link
Owner

Well, a little relief before update (I'll try to do it for 0.2.0, when the plugin gets more or less to the stable state):

Update notebook cell with keystroke

You can put this .js script in $HOME/.jupyter/custom/keystroke_update.js
and use u (IN JUPYTER NOTEBOOK, NOT VIM) to update modified cell.

@szymonmaszke szymonmaszke added the help wanted Extra attention is needed label Mar 1, 2018
@michaelfresco
Copy link

That is really sweet man. I think you have achieved something now that nobody has ever done. Vim and good python plotting, all from the vim terminal. I'm gonna try it out.

@michaelfresco
Copy link

michaelfresco commented Mar 2, 2018

I can't get that javascript too work though.

Still, pressing cmd R to get the browser to reload would be the killer feature. Ideally, all the graphs would render and you get an instant REPL effect.

@szymonmaszke
Copy link
Owner

@michaelfresco It is possible to configure Jupyter notebook to answer yes to all popups.
First, if you don't have jupyter config ($HOME/.jupyter) issue the following:

jupyter notebook --generate-config

Now navigate to to $HOME/.jupyter/jupyter_notebook_config.py, find the line #c.JupyterApp.answer_yes=False and change it to c.JupyterApp.answer_yes=True.

The script I provided is just a temporary workaround, not mine, and I can't give any guarantees about it.

@michaelfresco
Copy link

michaelfresco commented Mar 2, 2018

woot woot! - it all works.

Steps I did:

  1. Enabled c.JupyterApp.answer_yes = True in ~/.jupyter/jupyter_notebook_config.py.
  2. I then added this javascript in ~/.jupyter/custom/custom.js.

You should see an alert when reloading, or making a new jupyter notebook.

Okay, it works! Then disable the alert, and press R to run all cells.

alert("hello world")

Jupyter.keyboard_manager.command_shortcuts.add_shortcut('r', {
    help : 'run all cells',
    help_index : 'zz',
    handler : function (event) {
        IPython.notebook.execute_all_cells();
        return false;
    }}
);

Source script:
https://stackoverflow.com/a/40731714/3846189

@Chandlercjy
Copy link

Pretty Amazing Plugin! Looking forward to this new feature! And others too!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants