Customizing Jupyter notebook server welcome message

Hello hello,

I would need to customize the startup message that jupyter displays on startup. Now the relevant part I would like to change, looks something like:

Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
    http://0.0.0.0:8888/?token=xxxxxxxxxxx

As the users of the notebook server will be using it through an SSH tunnel, I would like to highlight the important parts of the above (and suppress the non-functioning and thus confusing parts). So instead, or at least in addition to the above, I would like to display something like:

Jupyter port: 8888
Jupyter token: xxxxxx...

To open up an SSH tunnel, use the following command:
ssh -N -L 8888:localhost:8889 username@servername 

Any hints on how to go about this? Is it possible to enable/specify a specific script to be run immediately after the server has started? Or should I edit directly the file that creates the “welcome” message? If so, which file is it?

Cheers,
Mikael

OK, replying to myself, as I found a solution. Not the prettiest, but works for my particular problem. The file to edit in my case was /usr/local/lib/python3.6/site-packages/notebook/notebookapp.py.

I did a rather quick-and-dirty replacement of the output strings. The following diff -c shows the changes:

*** notebookapp.py.original     2020-03-30 08:05:35.656975974 -0400
--- notebookapp.py      2020-03-30 08:47:29.511702921 -0400
***************
*** 26,31 ****
--- 26,33 ----
  import warnings
  import webbrowser

+ import pwd
+
  try: #PY3
      from base64 import encodebytes
  except ImportError: #PY2
***************
*** 1400,1410 ****
          if self.token and self._token_generated:
              # log full URL with generated token, so there's a copy/pasteable link
              # with auth info.
              self.log.critical('\n'.join([
                  '\n',
!                 'Copy/paste this URL into your browser when you connect for the first time,',
!                 'to login with a token:',
!                 '    %s' % url_concat(self.connection_url, {'token': self.token}),
              ]))

          self.io_loop = ioloop.IOLoop.current()
--- 1402,1420 ----
          if self.token and self._token_generated:
              # log full URL with generated token, so there's a copy/pasteable link
              # with auth info.
+             #self.log.critical('\n'.join([
+             #    '\n',
+             #    'Copy/paste this URL into your browser when you connect for the first time,',
+             #    'to login with a token:',
+             #    '    %s' % url_concat(self.connection_url, {'token': self.token}),
+             #]))
              self.log.critical('\n'.join([
                  '\n',
!                 'Jupyter port: %s' % self.port,
!                 'Jupyter token: %s' % self.token,
!                 '\nTo access your Jupyter notebook from your local computer:',
!                 '\n1. Create SSH tunnel: ssh -L 8890:localhost:%s %s@%s' % (self.port, pwd.getpwuid(os.getuid()).pw_name, socket.gethostname()),
!                 '2. Open browser link: http://127.0.0.1:8890/?token=%s' % self.token,
              ]))

          self.io_loop = ioloop.IOLoop.current()