1

I want to have JupyterLab launch and load custom settings and overwrite advanced settings automacally.

But I can't do it although I tried three method notebook.json/custom.js/config.js.

How can I do it?

My Environment

Versions

  • 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-configurator 0.4.1
    • jupyter-packaging 0.10.1
    • jupyter-server 1.6.4
    • jupyterlab 3.0.14
    • jupyterlab-pygments 0.1.2
    • jupyterlab-server 2.5.0

Directory

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

Settings

// ~/.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;
Moheji
  • 23
  • 5
  • You seem to be using Notebook settings for JupyterLab. You should be using [overrides.json](https://jupyterlab.readthedocs.io/en/stable/user/directories.html#overrides-json) instead (and the JSON schema is completely different from what you use above, but all have their corresponding entries). – krassowski May 09 '21 at 14:42
  • Does this answer your question? [JupyterLab User Settings File](https://stackoverflow.com/questions/48950670/jupyterlab-user-settings-file) – krassowski May 09 '21 at 14:43
  • @krassowski `override.json` may be help me. but I can't find its options for example linenumbers. Would you tell me web sites tells options of `override.json`? – Moheji May 09 '21 at 15:26
  • You basically need to go to the Advanced Settings Editor and find it there; the top-level key is the name of the extension (everything is an extension in JupyterLab), you can find it in the "System Defaults" panel (in the comment near the top). – krassowski May 09 '21 at 15:56

1 Answers1

1

Solved! Thank you for your advice, @krassowski!

Now, I can load Jupyterlab advanced settings when launching with {sys.prefix}/share/jupyter/lab/settings/override.json like below.

{
    "@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
        }
    }
}
Moheji
  • 23
  • 5