JupyterLab 启动时如何加载 notebook.json 或 custom.js?

How can JupyterLab load notebook.json or custom.js when JupyterLab launching?

我想让 JupyterLab 启动并加载自定义设置并自动覆盖高级设置。

可是试了三种方法都做不到notebook.json/custom.js/config.js.

我该怎么做?

我的环境

版本

目录

├ ~/
  ├ .jupyter/
    ├ nbconfig/
      ├ notebook.json
    ├ config/
      ├ config.js
    ├ custom/
      ├ custom.js

设置

// ~/.jupyter/nbconfig/notebook.json
{
    "load_extensions": {
        "codefolding/main": true
    },
    "MarkdownCell": {
        "cm_config": {
            "autoClosingBrackets": true,
            "lineNumbers": true,
            "lineWrapping": false
        }
    },
    "CodeCell": {
        "cm_config": {
            "lineNumbers": true,
            "lineWrapping": true
        }
    },
    "Cell": {
        "cm_config": {
            "lineNumbers": true,
            "lineWrapping": true
        }
    },
    "codeCellConfig": {
        "cm_config": {
            "tabSize": 4,
            "insertSpaces": true,
            "readOnly": false,
            "autoClosingBrackets": true,
            "matchBrackets": true,
            "lineNumbers": true,
            "lineWrapping": "wordWrapColumn",
            "wordWrapColumn": 95
        }
    }
}
// ~/.jupyter/custom/custom.js or ~/.jupyter/config/config.js
var cm_config = require('notebook/js/cell').Cell.options_default.cm_config;
cm_config.tabSize = 4;
cm_config.readOnly = false;
cm_config.lineNumbers = true;
cm_config.linWrapping = true;
// cm_config.wordWrapColumn = 95;
cm_config.autoClosingBrackets = true;

已解决!感谢您的建议,@krassowski!

现在,我可以在使用 {sys.prefix}/share/jupyter/lab/settings/override.json 启动时加载 Jupyterlab 高级设置,如下所示。

{
    "@jupyterlab/apputils-extension:themes": {
        "theme": "JupyterLab Dark"
    },
    "@jupyterlab/notebook-extension:tracker": {
        "markdownCellConfig": {
            "autoClosingBrackets": true,
            "lineNumbers": true,
            "lineWrap": "off"
        },
        "rawCellConfig": {
            "lineNumbers": true,
            "lineWrap": "wordWrapColumn",
            "wordWrapColumn": 130
        },
        "codeCellConfig": {
            "tabSize": 4,
            "insertSpaces": true,
            "readOnly": false,
            "codeFolding": false,
            "autoClosingBrackets": true,
            "matchBrackets": true,
            "lineNumbers": true,
            "lineWrap": "wordWrapColumn",
            "wordWrapColumn": 130
        }
    }
}