Skip to main content

Z shell kernel for Jupyter

Project description

zsh kernel for jupyter

screenshot

a simple z shell jupyter kernel powered by python 3, pexpect and enthusiasm.

i love experimentation and tinkering, but usual shell terminals does not allow developing multiple different code snippets at once conveniently. with shell kernels you can turn your scripts into notebooks!

if you find this product useful, please consider supporting me with a one-time tip.

installation

  1. install the python package from pypi.
  2. install the jupyter kernel spec using python script install in the zsh_jupyter_kernel module. check python -m zsh_jupyter_kernel.install -h for possible installation options. default installation will install the kernel in the user location. use --sys-prefix option if you want to install the kernel in your current virtual environment.

see some common installation examples below.

pipenv

pipenv --python 3.10 install notebook zsh_jupyter_kernel
pipenv run python -m zsh_jupyter_kernel.install --sys-prefix

pip

python -m pip install notebook zsh_jupyter_kernel
python -m zsh_jupyter_kernel.install --sys-prefix

technical overview

the kernel launches zsh as if it was a regular process launched from your terminal with a few minor settings to make sure it works with jupyter. there is slight chance it wont work with super complicated zshrc setups, but it works with majority of configs including oh-my-zsh.

how does code execution work

the kernel configures zsh prompt string to its own custom value. when a user requests a cell execution, the code is sent to the kernel. then the kernel puts the frontend on hold, sends the code to zsh process, and waits for the prompt string to release the frontend and let the user request more code execution.

code completion

code completion is powered by quite a non-trivial script that involves multiple steps, including spawning another temporary zsh process and capturing completion options into a data structure that jupyter frontend understands.

code inspection

code inspection is done by man --pager ul which sends the whole man page to the frontend.

code completeness

code completeness is checked with the temporary zsh process and help of EXEC zsh option, which allows switching off code execution and simply check if the code is complete using the exit code of the zsh process itself.

stderr

stderr content is just sent to the front-end as regular stdout.

stdin

stdin is not supported because of the execution system when a process spawned by a user waits for stdin, there is no way to detect it.

missing features

  • history
  • rich html output for things like images and tables
  • stdin. might be possible with or without the current system
  • pagers. might be possible or not
  • stored and referenceable outputs

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

zsh-jupyter-kernel-3.5.0.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

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

zsh_jupyter_kernel-3.5.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file zsh-jupyter-kernel-3.5.0.tar.gz.

File metadata

  • Download URL: zsh-jupyter-kernel-3.5.0.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for zsh-jupyter-kernel-3.5.0.tar.gz
Algorithm Hash digest
SHA256 a0c18ff6a2e12848cdcaafcc072ea19e8f8db0a78667ad6f0871035ae6d85b79
MD5 bad95661bfb3c78094c3cd5fde507112
BLAKE2b-256 9853338ad96eea8bef36370907d2c814f3b63805e4c88b13b1e36b4fa7c028bb

See more details on using hashes here.

File details

Details for the file zsh_jupyter_kernel-3.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for zsh_jupyter_kernel-3.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f1b96b44698c4e004fa124aa90eed8ce5038370edb66173de39300493c93a72
MD5 1e2056e7ef798226476008780d4b9f3b
BLAKE2b-256 16179cb593f5561b947c5814e818bfe00ffcf41e5e3dff60803109c311f25c5b

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