Jupyter Snippet CB2nd 05_custom_notebook

Jupyter Snippet CB2nd 05_custom_notebook

3.5. Configuring the Jupyter Notebook

%ls ~/.jupyter/jupyter_notebook_config.py
~/.jupyter/jupyter_notebook_config.py
%cat ~/.jupyter/jupyter_notebook_config.py
# Configuration file for jupyter-notebook.

#-------------------------------------------------------
# Application(SingletonConfigurable) configuration
#-------------------------------------------------------

## This is an application.

## The date format used by logging formatters
#c.Application.log_datefmt = '%Y-%m-%d %H:%M:%S'

[...]

#-------------------------------------------------------
# JupyterApp(Application) configuration
#-------------------------------------------------------

## Base class for Jupyter applications

## Answer yes to any prompts.
#c.JupyterApp.answer_yes = False

## Full path of a config file.
#c.JupyterApp.config_file = ''

...
c.ContentsManager.untitled_notebook = 'MyNotebook'
%ls ~/.jupyter/nbconfig/
notebook.json  tree.json
%cat ~/.jupyter/nbconfig/notebook.json
{
  "Cell": {
    "cm_config": {
      "lineNumbers": false
    }
  },
  "Notebook": {
    "Header": false,
    "Toolbar": false
  }
}
%%javascript
var cell = Jupyter.notebook.get_selected_cell();
var config = cell.config;
var patch = {
      CodeCell:{
        cm_config: {autoCloseBrackets: false}
      }
    }
config.update(patch)
%cat ~/.jupyter/nbconfig/notebook.json
{
  "Cell": {
    "cm_config": {
      "lineNumbers": false
    }
  },
  "Notebook": {
    "Header": false,
    "Toolbar": false
  },
  "CodeCell": {
    "cm_config": {
      "autoCloseBrackets": false
    }
  }
}
from notebook.services.config import ConfigManager
c = ConfigManager()
c.get('notebook').get('CodeCell')
{'cm_config': {'autoCloseBrackets': False}}
c.update('notebook', {"CodeCell":
         {"cm_config": {"autoCloseBrackets": True}}})
{'Cell': {'cm_config': {'lineNumbers': False}},
 'CodeCell': {'cm_config': {'autoCloseBrackets': True}},
 'Notebook': {'Header': False, 'Toolbar': False}}
%cat ~/.jupyter/nbconfig/notebook.json
{
  "Cell": {
    "cm_config": {
      "lineNumbers": false
    }
  },
  "Notebook": {
    "Header": false,
    "Toolbar": false
  },
  "CodeCell": {
    "cm_config": {
      "autoCloseBrackets": true
    }
  }
}

There’s more…

See also