Search code examples
bashjupyterjupyter-labjupyterhub

How to login to bash with current user, and the user's .bashrc file, in jupyterlab?


I have a configuration file setup in .bashrc which I would like to apply to all terminals opened automatically in my jupyterlab.

Currently jupyterlab terminals start like this, without any of the configuration in my .bashrc file.

jupyterlab terminal

If I simply type bash and hit enter it does exactly what I want. Like below.

terminal after typing bash

I would like for it to automatically open like this.

How can this be achieved?

Here is a very similar question.

But none of the solutions work, I mean it does open bash, not shell, so I'm not sure if that solution is what I'm looking for. But I've changed my tornado settings, I've added the environment variable SHELL=/bin/bash but none of it has any affect. (I've obviously restarted jupyterhub each time to see the effect.

Here is my jupyterhub start file 'jupyterhub.service', located in '/etc/systemd/'.

[Unit]
Description=Jupyterhub
After=syslog.target network.target
[Service]
User=root
Type=simple
Environment="PATH=/anaconda3/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
Environment="SPARK_HOME=/spark-2.3.2-bin-hadoop2.7/"
Environment="SHELL=/bin/bash"
ExecStart=/anaconda3/bin/jupyterhub -f /etc/jupyter/jupyterhub_config.py
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target

Solution

  • You could try creating a file

    $HOME/.bash_login
    

    and source .bashrc from there

    source $HOME/.bashrc
    

    and see if it does what you wanted.