⚠️ Archived 2025-08-25. No longer maintained.
A script that lets you add the current VMware Tanzu Mission Control (TMC) context, management cluster and provisioner to your Bash prompt.
Currently supporting Starship as well as your generic $PS1.
Inspired by the super useful kube-ps1
- Make sure you have the
tmcCLI installed. - Clone this repository
- Source tmc_prompt.sh, e.g
. /path/to/tmc_prompt.sh. You can also source this script from your Bash runcom, e.g.~/bashrcto persist the prompt across bash sessions and add any of the configuration overides explained below. - Run
tmc_configure_promptto install the prompt
tmc_configure_prompt shows or installs a custom prompt for TMC. Any further overrides can be performed in ~/.config/starship.toml as described in the Starship documentation.
Even if you're just using the basic Bash prompt, tmc_configure_prompt can update your $PROMPT_COMMAND environment variable and provide a helper function to toggle the visibility of the TMC prompt.
Of course, you can also simply source tmc_prompt.sh and set $PS1
source /path/to/tmc_prompt.sh
export PS1=tmc_promptSourcing tmc_prompt.sh provides the following functions
| Function Name | Use |
|---|---|
| tmc_defaults | Toggles the visibility of the TMC defaults in the prompt string using args on or off |
| tmc_prompt | Displays the TMC prompt or, when used with args on or off, toggles the visibility of the TMC prompt |
| tmc_configure_prompt | Configure the TMC prompt for the supported prompt implementation |
Executing tmc_prompt.sh directly will echo the TMC prompt string.
There are some options to override the construction of the prompt.
The TMC prompt format is defined using the following tokens
| Token | Meaning |
|---|---|
#CONTEXT# |
Current TMC context |
#DEFAULTS# |
Current TMC defaults |
#MGMT_CLUSTER# |
Default management cluster |
#PROVISIONER# |
Default provisioner |
The default settings can be overridden by setting the following environment variables:
| Variable | Default | Meaning |
|---|---|---|
TMC_PROMPT_FORMAT |
⏣ #CONTEXT# #DEFAULTS# |
Default prompt format |
TMC_PROMPT_DEFAULTS_FORMAT |
(#MGMT_CLUSTER# ⇢ #PROVISIONER#) |
Format of TMC defaults in the prompt |
Use tmc_defaults on to display the TMC defaults and tmc_defaults off to hide them.
Use tmc_prompt on to make the TMC prompt visible and tmc_prompt off to hide it.
You can use the tmctx, tmcmc and tmcp utilites to help switch between TMC CLI contexts, management clusters and provisioners.
If you're curious about the TMC CLI and looking for examples, take a look at my scripts I use to understand the usability and functionality of the TMC CLI.
Also, if you're at all interested in CLI taxonomy, check out cli_taxo.
