JupyterLab 启动时如何加载 notebook.json 或 custom.js?
How can JupyterLab load notebook.json or custom.js when JupyterLab launching?
我想让 JupyterLab 启动并加载自定义设置并自动覆盖高级设置。
可是试了三种方法都做不到notebook.json
/custom.js
/config.js
.
我该怎么做?
我的环境
版本
- python:3.9.1
- jupyter-client 6.1.12
- jupyter-contrib-core 0.3.3
- jupyter-contrib-nbextensions 0.5.1
- jupyter-core 4.7.1
- jupyter-highlight-selected-word 0.2.0
- jupyter-latex-envs 1.4.6
- jupyter-nbextensions-配置器 0.4.1
- jupyter-packaging 0.10.1
- jupyter 服务器 1.6.4
- jupyterlab 3.0.14
- jupyterlab-pygments 0.1.2
- jupyterlab 服务器 2.5.0
目录
├ ~/
├ .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
}
}
}
我想让 JupyterLab 启动并加载自定义设置并自动覆盖高级设置。
可是试了三种方法都做不到notebook.json
/custom.js
/config.js
.
我该怎么做?
我的环境
版本
- python:3.9.1
- jupyter-client 6.1.12
- jupyter-contrib-core 0.3.3
- jupyter-contrib-nbextensions 0.5.1
- jupyter-core 4.7.1
- jupyter-highlight-selected-word 0.2.0
- jupyter-latex-envs 1.4.6
- jupyter-nbextensions-配置器 0.4.1
- jupyter-packaging 0.10.1
- jupyter 服务器 1.6.4
- jupyterlab 3.0.14
- jupyterlab-pygments 0.1.2
- jupyterlab 服务器 2.5.0
目录
├ ~/
├ .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
}
}
}