jlconlin
jlconlin

Reputation: 15074

How to configure JupyterLab to look the same when opened?

I'm developing a small application using JupyterLab that I will distribute around the world. I would like to configure JupyterLab so that when my users download my code, move into the directory, and execute jupyter-lab, they will always start with the same view.

For example, I want JupyterLab to open up with the README.md file shown rendered as markdown. I don't want Python or Jupyter Notebook files opened (initially).

Is there a way to configure JupyterLab in this way?*

Upvotes: 1

Views: 935

Answers (1)

krassowski
krassowski

Reputation: 15419

You can use jupyterlab-workspace.json file to specify layout. Here are some examples:

They work by executing the following command before starting up JupyterLab:

jupyter lab workspaces import jupyterlab-workspace.json

Do NOT try to create the JSON file manually (do not use them as a reference). Instead create a new workspace, arrange tabs/files as you wish and then use:

jupyter lab workspaces export workspace_name > jupyterlab-workspace.json

See the workspaces documentation for more details. There is also a relevant topic on discourse.

For your particular use case I would just create a file with a script that your users would use instead of executing jupyter-lab, e.g. a simple two-liner like:

jupyter-lab workspaces import jupyterlab-workspace.json
jupyter-lab

But if you just want one single file to be shown you may as well just create a wrapper that asks for that file to be opened like:

jupyter-lab README.md

Please note that there was a bug that meant that above did not work some time ago (it is working well if you have the latest versions of jupyterlab-server, jupyter-server, jupyterlab; while updating remember to update nbclassic - if installed - as well).

Upvotes: 1

Related Questions