I speak here {^_^}

Notes: customizing starship! #27

July 25, 2021

On my local machine, I use a starship cross-shell prompt setup on top of bash (which I truly find as a very handy tool!)

So, as part of my day to day work, I require to spin up or connect to multiple kubernetes & OpenShift clusters at a time. Although starship has an inbuilt kubernetes module, to dynamically configure the shell prompt based on the currently active kubernetes cluster, but for some reason, it never reflected on my kubernetes/OpenShift cluster logins (so far).

And I also didn’t realise that until now, because most of the times, I used a python-based tooling to login into multiple clusters in a containerized manner (in simple words, each cluster login happened in a separate docker container (& not on my host machine)).

And, so the few times, I spinned up local clusters, well, I didn’t notice much. And at other times, on the docker container shell (created for cluster logins), it had custom bash prompts, (& ofcourse, no starship), so, again, it never stuck me.

But today, I was trying to add starship to the above python tooling contianer image & then I realised for the first time, that it didn’t pick up any of the cluster configs or the active namespace value (basically all stuff that the starship’s kubernetes module look for, to configure the prompt accordingly).

So, then I was looking for ways to set up a custom config for starship, to help with this scenario.

Well, it was easy (after a little while of wasted time, in random blind internet search). The official documentation for starship talks about the steps required to add custom configurations..

The default configuration path for the starship is set to ~/.config/starship.toml (which is something that’s not created at the time of fresh install. FYI, starship config command gives you the path.)

So, below are the (very quick) steps that I followed to configure starship to work my with requirements for the kubernetes/OpenShift clusters.

  • create the config file

    mkdir -p ~/.config && touch ~/.config/starship.toml

  • edit the ~/.config/starship.toml file & add the following (⬇️) & save the changes.

    symbol = "☸️  "
    style = "green"
    disabled = false
    style_user = "bold blue"
    show_always = true

Yea, that’s all what was required. The prompt right away, started picking up the changes & showing the required stuff.

psaggu on ☸️  test-openshift-cluster/psaggu-cssre (test-namespace) took 42s