Skip to content

Commit

Permalink
Merge pull request jupyter-server#343 from kevin-bates/port-5565-5588
Browse files Browse the repository at this point in the history
Port Notebook PRs 5565 and 5588 - terminal shell heuristics
  • Loading branch information
Zsailer committed Dec 1, 2020
2 parents 8072051 + cd56802 commit 5b3c146
Showing 1 changed file with 11 additions and 3 deletions.
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

0 comments on commit 5b3c146

Please sign in to comment.