Skip to content

Instantly share code, notes, and snippets.

@patricksnape
Created January 11, 2014 18:56
Show Gist options
  • Save patricksnape/8375168 to your computer and use it in GitHub Desktop.
Save patricksnape/8375168 to your computer and use it in GitHub Desktop.
IPython restart and run all above shortcuts
%%javascript
IPython.keyboard_manager.command_shortcuts.add_shortcut('r', function (event) {
if (IPython.notebook.mode == 'command') {
var selected_cell = IPython.notebook.get_selected_index();
IPython.notebook.session.restart_kernel();
$([IPython.events]).on('status_started.Kernel', function(){
IPython.notebook.execute_cells_above();
});
return false;
}
return true;
});
IPython.keyboard_manager.command_shortcuts.add_shortcut('q', function (event) {
if (IPython.notebook.mode == 'command') {
IPython.notebook.clear_all_output();
return false;
}
return true;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment