Skip to content

Added extra_env in terminado_settings #1543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions jupyter_server/serverapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1488,10 +1488,18 @@ def _default_allow_remote(self) -> bool:
"""
),
)

terminado_settings = Dict(
Union([List(), Unicode()]),
per_key_traits={
"shell_command": Union(
[List(), Unicode()], help="The shell command to execute in the terminal."
),
"extra_env": Dict(
Unicode(), help="Extra environment variables to set in the terminal."
),
},
config=True,
help=_i18n('Supply overrides for terminado. Currently only supports "shell_command".'),
help=_i18n("Supply overrides for terminado."),
)

cookie_options = Dict(
Expand Down
11 changes: 11 additions & 0 deletions tests/test_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,17 @@ def test_shell_command_override(
assert app.web_app.settings["terminal_manager"].shell_command == expected_shell


def test_terminal_extra_env_override(jp_configurable_serverapp):
config = Config({"ServerApp": {"terminado_settings": {"extra_env": {"PS1": "jupyter> "}}}})

app = jp_configurable_serverapp(config=config)
terminado_settings = getattr(app, "terminado_settings", {})

assert "extra_env" in terminado_settings
assert "PS1" in terminado_settings["extra_env"]
assert terminado_settings["extra_env"]["PS1"] == "jupyter> "


def test_importing_shims():
with warnings.catch_warnings():
warnings.simplefilter("ignore")
Expand Down
Loading