Skip to content
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

Port Notebook PRs 5565 and 5588 - terminal shell heuristics #343

Merged
merged 2 commits into from
Dec 1, 2020
Merged
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
14 changes: 11 additions & 3 deletions jupyter_server/terminal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys

import terminado
from ..utils import check_version
Expand All @@ -19,11 +20,18 @@ def initialize(webapp, root_dir, connection_url, settings):
default_shell = 'powershell.exe'
else:
default_shell = which('sh')
shell = settings.get('shell_command',
shell_override = settings.get('shell_command')
shell = (
[os.environ.get('SHELL') or default_shell]
if shell_override is None
else shell_override
)
# Enable login mode - to automatically source the /etc/profile script
if os.name != 'nt':
# When the notebook server is not running in a terminal (e.g. when
# it's launched by a JupyterHub spawner), it's likely that the user
# environment hasn't been fully set up. In that case, run a login
# shell to automatically source /etc/profile and the like, unless
# the user has specifically set a preferred shell command.
if os.name != 'nt' and shell_override is None and not sys.stdout.isatty():
shell.append('-l')
terminal_manager = webapp.settings['terminal_manager'] = NamedTermManager(
shell_command=shell,
Expand Down