jupyter_server
jupyter_server copied to clipboard
Allow to pass `extra_env` down to terminado to set `PS1` variable in terminals
Problem
We need a way to set the terminal prompt (e.g. with PS1 environment variable) for reproducible snapshots as in https://github.com/jupyterlab/jupyterlab/pull/17656. This may be also desirable for real deployments. While terminado classes accept both shell_command and extra_env, the latter is not currently supported in jupyter-server traitlet definition:
https://github.com/jupyter-server/jupyter_server/blob/04dd3e7af0f6632ff4fe01bcc1e05ec0731d369c/jupyter_server/serverapp.py#L1491-L1495
Proposed Solution
Use per-key traitlets to accept shell_command as an union of string/list and extra_env as a dict with string keys.
Additional context
Need to add a test around here:
https://github.com/jupyter-server/jupyter_server/blob/04dd3e7af0f6632ff4fe01bcc1e05ec0731d369c/tests/test_terminal.py#L278-L297