Customizing shell launched by terminal

Hi all,

Is there a way to configure the shell used by the Terminal launcher? The docs don’t seem to mention anything in this respect.

More specifically: on my local computer, JupyterLab uses my login shell, so changing it with chsh works. However, on a remote server with JupyterHub that I manage, it always uses bash, irrespective of which login shell is set (I suspect it may have something to do with SystemdSpawner, which is used to spawn the individual single-user servers).

So I was wondering if I can customize the shell somewhere within JupyterLab’s own settings instead :slight_smile:

So I came across two recommendations – either set SHELL under /etc/environment, or create a site-wide jupyter_notebook_config.py under /etc/jupyter (this issue pointing to the JupyterHub docs was particularly helpful, thanks!).

The first suggestion – modifying /etc/environment – did not work, but what did work was setting Environment=SHELL=/usr/bin/fish in the systemd service file I’ve set up to launch JupyterHub. So it seems setting the SHELL env var indeed does it, it’s just that it’s not picked up from /etc/environment and has to be set somewhere else.

The second suggestion worked as advertised, so just for reference or anyone else trying to do this, since it’s independent of the way you launch JupyterHub – just put this in your /etc/jupyter/jupyter_notebook_config.py:

c.NotebookApp.terminado_settings = { "shell_command": ["/usr/bin/fish"] }

This variant is also more flexible, since you can provide additional arguments to the shell command, e.g. forcing a login shell.

2 Likes

You mentioned that you can provide additional arguments to the shell command. Am I right in assuming you mean by adding flags to ["/usr/bin/fish"] rather than passing in other keys to the terminado_settings dictionary?

Yes exactly, just append additional arguments as elements of that list.

1 Like

Is there any way to do this that does not involve modifying a global configuration variable. I would like to be able to set the shell used from a user setting.

You should be able to create that exact same configuration file above in any of the Jupyter config directories, not just /etc/jupyter/jupyter_notebook_config.py. To see the list of config directories, use jupyter --paths. For example, for me, I can create such a config file in /Users/[my username]/.jupyter/jupyter_notebook_config.py

4 Likes

I’m still a bit confused. Running tljh, getting the default bash. If i want to run the user’s login shell as seen in /etc/passwd (i always change my users to zsh/oh-my-zsh login shells) how do i specify this in the config file? Thought of /usr/bin/env $SHELL but then thought would be handled as the user the tljh server runs as…

Is the only option to have the user set their own config?