0

Similar to the question in here, I am trying to start a Jupyter Lab server with some custom settings (e.g. keyboard shortcuts, Notebook settings (e.g. autoclose brackets), dark themes).

  1. How do I write this settings file?
  2. How do I specify this when starting up the jupyter lab server?

For e.g. I would like to set the following settings/shortcut when starting the jupyter lab server.

  • Dark Theme as Default
  • Keyboard Shortcut "Shift Backspace" for Run> Restart-and-run-all

So far, I created a file called overrides.json with the following contents

{
    "theme": "JupyterLab Dark"
}
"shortcuts": [
           {
              "command": "runmenu:restart-and-run-all",
              "keys": [

                "Shift Backspace"
              ],
              "selector": "[data-jp-code-runner]",
              "title": "Restart Kernel and Run All",
              "category": "Run Menu"
            },

Then I started the jupyter lab server with

jupyter lab --ip=0.0.0.0 --port=8888 --allow-root --no-browser --notebook-dir=/workspace --config=/workspace/overrides.json

This did not change anything when the new server started.

ajikodajis
  • 15
  • 4

1 Answers1

1

Answering my own question in case someone finds it useful. A couple of things are wrong with what I did.

  1. The files with the user-defined setting should be put into the settings directory inside JupyterLab Application Directory as mentioned here. More specifically, the correct path to put the config file is <sys-prefix>/share/jupyter/lab/settings where sys-prefix can be obtained by running jupyter lab path.

The following bash command basically does this for you.

# Create a setting directory inside the Application directory
jupyter lab path | sed -n 's/Application directory:\s*\(.*\)/mkdir -p \1\/settings/p' | sh
# Copy the configurations file called overrides.json to that directory
jupyter lab path | sed -n 's/Application directory:\s*\(.*\)/cp ./overrides.json \1\/settings/p' | sh
  1. The overrides.json file needs to follows a certain format that I did not follow in my original post. The correct contents of the file should be
{
 "@jupyterlab/shortcuts-extension:shortcuts":
        {
                 "shortcuts": [
           {
              "command": "runmenu:restart-and-run-all",
              "keys": [

                "Shift Backspace"
              ],
              "selector": "[data-jp-code-runner]",
              "title": "Restart Kernel and Run All",
              "category": "Run Menu"
            }
        },

"@jupyterlab/apputils-extension:themes":
        {
                "theme": "JupyterLab Dark"
        }
}
ajikodajis
  • 15
  • 4