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



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

虽然我尝试了notebook.json/custom.js/config.js三种方法,但我做不到。

我该怎么做?

我的环境

版本

  • python:3.9.1
    • jupyter客户端6.1.12
    • 木星contrib核心0.3.3
    • 木星贡献0.5.1
    • 木星核心4.7.1
    • jupyter高亮显示所选单词0.2.0
    • jupyter乳胶envs 1.4.6
    • jupyter扩展配置程序0.4.1
    • jupyter包装0.10.1
    • jupyter服务器1.6.4
    • 木星3.0.14
    • 木星碎片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
}
}
}

最新更新