Giter VIP home page Giter VIP logo

tmc-prompt's Introduction

tmc-prompt

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.

starship prompt example

asciicast

Inspired by the super useful kube-ps1

Installing

  1. Make sure you have the tmc CLI installed.
  2. Clone this repository
  3. Source tmc_prompt.sh, e.g . /path/to/tmc_prompt.sh. You can also source this script from your Bash runcom, e.g. ~/bashrc to persist the prompt across bash sessions and add any of the configuration overides explained below.
  4. Run tmc_configure_prompt to install the prompt

Starship prompt framework

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.

Generic Bash prompt

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_prompt

Helper functions

Sourcing 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.

Options

There are some options to override the construction of the prompt.

Prompt format

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

Toggling the visibility of the TMC defaults

Use tmc_defaults on to display the TMC defaults and tmc_defaults off to hide them.

Toggling the visibility of the TMC prompt

Use tmc_prompt on to make the TMC prompt visible and tmc_prompt off to hide it.

Other Tanzu Mission Control CLI stuff

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.

tmc-prompt's People

Contributors

ali5ter avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.