Skip to main content

A terminal for JupyterLite

Project description

JupyterLite Terminal

Github Actions Status lite-badge

A terminal for JupyterLite.

a screenshot showing a terminal running in JupyterLite

Requirements

  • JupyterLite >= 0.7.0, < 0.9.0

Install

To install the extension, execute:

pip install jupyterlite-terminal

You will also need to install the JupyterLite CLI:

python -m pip install jupyterlite-core

Usage

After installing jupyterlite-core and jupyterlite-terminal, create a jupyter-lite.json file with the following content to activate the terminal extension:

{
  "jupyter-lite-schema-version": 0,
  "jupyter-config-data": {
    "terminalsAvailable": true
  }
}

Then build a new JupyterLite site:

jupyter lite build

Running commands programmatically

Besides the interactive terminal, the extension registers JupyterLab commands that run commands in a headless cockle shell: one that captures the output and exit code without opening a terminal widget. These are useful for other extensions or automation that need to run shell commands in JupyterLite.

Command Description
@jupyterlite/terminal:execute-shell Run a command and return its output and exit code
@jupyterlite/terminal:start-shell Start a reusable headless shell
@jupyterlite/terminal:shutdown-shell Shut down a headless shell by name
@jupyterlite/terminal:list-shells List the running headless shells

Run a single command (a throwaway shell is created and disposed automatically):

const result = await app.commands.execute('@jupyterlite/terminal:execute-shell', {
  code: 'echo hello'
});
console.log(result.exitCode); // 0
console.log(result.output); // hello

Pass a shellName to reuse a shell across calls so state such as the working directory persists:

const { shellName } = await app.commands.execute('@jupyterlite/terminal:start-shell');
await app.commands.execute('@jupyterlite/terminal:execute-shell', {
  code: 'cd /drive',
  shellName
});
const result = await app.commands.execute('@jupyterlite/terminal:execute-shell', {
  code: 'pwd',
  shellName
});
console.log(result.output); // /drive

Each command runs as a single cockle pipeline, so |, ; and redirections (>, >>, 2>, <) work, but &&/||, command substitution and $VAR expansion are not supported.

Version compatibility

Each jupyterlite-terminal release is built against a specific version of cockle. If you need to include imports from both jupyterlite-terminal and cockle, such as if you are implementing cockle external commands, you should ensure that you are using the correct version combination.

jupyterlite-terminal cockle jupyterlite-core Release date
1.5.1 1.6.0 >= 0.7, < 0.9, != 0.7.4, != 0.7.5 2026-06-25
1.5.0 1.6.0 >= 0.7, < 0.9, != 0.7.4, != 0.7.5 2026-06-24
1.4.1 1.5.1 >= 0.7, < 0.8, != 0.7.4, != 0.7.5 2026-05-14
1.4.0 1.5.0 >= 0.7, < 0.8, != 0.7.4, != 0.7.5 2026-05-06
1.3.1 1.4.1 >= 0.7, < 0.8, != 0.7.4 2026-03-25
1.3.0 1.4.0 >= 0.7, < 0.8 2026-03-02
1.2.0 1.3.0 >= 0.7, < 0.8 2025-12-03
1.1.0 1.2.0 >= 0.6, < 0.8 2025-10-27
1.0.1 1.0.0 >= 0.6, < 0.8 2025-09-03
1.0.0 1.0.0 >= 0.6, < 0.7 2025-08-11
0.2.2 0.1.3 >= 0.6, < 0.7 2025-06-27

Contributing

Development install

Note: You will need NodeJS to build the extension package.

The jlpm command is JupyterLab's pinned version of yarn that is installed with JupyterLab. You may use yarn or npm in lieu of jlpm below.

# Clone the repo to your local environment
# Change directory to the jupyterlite_terminal directory
# Install package in development mode
pip install -e "."
# Link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# Rebuild extension Typescript source after making changes
jlpm build

You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.

# Watch the source directory in one terminal, automatically rebuilding when needed
jlpm watch
# Run JupyterLab in another terminal
jupyter lab

Then build a JupyterLite distribution with the extension installed:

cd deploy
jupyter lite build --contents contents

And serve it either using:

npx static-handler _output/

or:

jupyter lite serve

To enable use of SharedArrayBuffer rather than ServiceWorker for stdin you will have to configure your server to add the Cross-Origin-Embedder-Policy and Cross-Origin-Opener-Policy headers. Do this using either:

npx static-handler --cors --coop --coep --corp _output/

or:

jupyter lite serve --LiteBuildConfig.extra_http_headers=Cross-Origin-Embedder-Policy=require-corp --LiteBuildConfig.extra_http_headers=Cross-Origin-Opener-Policy=same-origin

Building the documentation

The project documentation includes a demo deployment, and is built on every PR so that the changes can be checked manually before merging. To build the documentation and demo locally use:

micromamba create -f docs/environment-docs.yml
micromamba activate terminal-docs
pip install -v .
cd docs
make html

To serve this locally use:

cd _build/html
python -m http.server

Packaging the extension

See RELEASE

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyterlite_terminal-1.5.1.tar.gz (821.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jupyterlite_terminal-1.5.1-py3-none-any.whl (100.9 kB view details)

Uploaded Python 3

File details

Details for the file jupyterlite_terminal-1.5.1.tar.gz.

File metadata

  • Download URL: jupyterlite_terminal-1.5.1.tar.gz
  • Upload date:
  • Size: 821.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for jupyterlite_terminal-1.5.1.tar.gz
Algorithm Hash digest
SHA256 87362244db1542ba2d79fc79b3434f11d8e4eb7ce717a1463dc33740a5d26e4b
MD5 babc54bc3ab7ae1e8aeb8b3b22ee0a56
BLAKE2b-256 42e880689ab83453bcf009d670d2d25df68bc7596724050fe85f5cba21d57964

See more details on using hashes here.

File details

Details for the file jupyterlite_terminal-1.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for jupyterlite_terminal-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 46072c50540e4cf961ea266415a8c344c798f6483f67e50945626da1ffb1098c
MD5 79f784bdeb1e355e9f54128c22059a19
BLAKE2b-256 d9fc402aaede364e39e9ec231c2a521461ff54289642730aeccd9f39aaf6f7d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page