Simplifying the command line prompt in JupyterLab

Right now the command-line prompt in the terminal can be quite long because it’s using the default <username>:<server>:<path> or something along those lines. For example:

image

Here, the jovyan username and the hostname (jupyter-rok-2eroskar-ontology-2dplayground-2d16a6d552) mean absolutely nothing to the user except that they clutter the limiter terminal real-estate. What if we made it something like

ontology-playground@12345:/work/ontology-playground $ 

12345 here is the commit hash. We can limit the number of characters in any of those components to make something short, readable and informative. Any other suggestsions?

I use the bobthefish theme in fish to add useful information to my prompt:

image

The git info indicates whether I’m in a git repo, if so the branch (if other than master), untracked files by color, and whether the local is different from origin ("+" indicates that my local is ahead of origin)

Here is the same prompt on master:

image

I think we should use Powerline to do something similar in our interactive environments:

If that is too heavyweight, we can at least get some git information into the prompt:

Yes, this was my thinking as well but I thought maybe it would be confusing for people who don’t know about these fancy shell prompts. A stripped down powerline might be what we need though.

I agree with this simplification! I think it makes sense to see the project name & the commit hash seems particularly useful since the notebook was launched from the state at this commit hash, even if you commit extra stuff, so it’s a useful comparison hash to diff on

it would be great if there was (an easily) user-selectable choice:

  • sometimes, just appending an enter after that long prompt is all that is needed
  • other times (what I’d probably favour most of the time), a prompt like cramakri’s would work best
  • other folks would opt for a minimal prompt up to a single character

In short, let’s give choice rather than taking it and provide a default that’s meaningful for most cases.

2 Likes

I think rather than providing a bunch of choices we can give a simple default that makes sense and document how to change it. This would then be something that the user would put in their renku-env repo on gitlab so their preferences are automatically injected at runtime.

1 Like

Alright, after some struggles with powerline fonts, I’ve got something that works and looks nice I think. Here’s a screenshot:

Looks good! On Renku we can drop the username and machine name from the prompt tooo.

I kept the username (well the container user name is jovyan so I add the actual username) - do you think it should go?

there is no machine name, btw - just username, path, and git info

I personally do not think the username is necessary.

This was done in https://github.com/SwissDataScienceCenter/renku-jupyter/pull/75 and has been merged!

1 Like