ccloud prompt¶
Attention
The Confluent Cloud CLI is deprecated and will stop working on May 9, 2022. All ccloud features have been moved to the Confluent CLI. To update to the new CLI, run ccloud update –major. See the Migrate to Confluent CLI v2 for more details.
Description¶
Use this command to add ccloud information in your terminal prompt.
For Bash, you’ll want to do something like this:
export PS1="\$(ccloud prompt) $PS1"
ZSH users should be aware that they will have to set the ‘PROMPT_SUBST’ option first:
setopt prompt_subst
export PS1="\$(ccloud prompt) $PS1"
You can customize the prompt by calling passing a ‘–format’ flag, such as ‘-f “ccloud|%E:%K”’. If you want to create a more sophisticated prompt (such as using the built-in color functions), it’ll be easiest for you if you use an environment variable rather than try to escape the quotes.
export CCLOUD_PROMPT_FMT='({{color "blue" "ccloud"}}|{{color "red" "%E"}}:{{color "cyan" "%K"}})'
export PS1="\$(ccloud prompt -f '$CCLOUD_PROMPT_FMT') $PS1"
To make this permanent, you must add it to your bash or zsh profile.
Formats¶
‘ccloud prompt’ comes with a number of formatting tokens. What follows is a list of all tokens:
‘%C’ or {{.ContextName}}
The name of the current context in use. E.g., “dev-app1”, “stag-dc1”, “prod”
‘%e’ or {{.EnvironmentId}}
The ID of the current environment in use. E.g., “a-4567”
‘%E’ or {{.EnvironmentName}}
The name of the current environment in use. E.g., “default”, “prod-team1”
‘%k’ or {{.KafkaClusterId}}
The ID of the current Kafka cluster in use. E.g., “lkc-abc123”
‘%K’ or {{.KafkaClusterName}}
The name of the current Kafka cluster in use. E.g., “prod-us-west-2-iot”
‘%a’ or {{.KafkaAPIKey}}
The current Kafka API key in use. E.g., “ABCDEF1234567890”
‘%u’ or {{.UserName}}
The current user or credentials in use. E.g., “joe@montana.com”
Colors¶
There are special functions used for controlling colors.
- {{color “<color>” “some text”}}
- {{fgcolor “<color>” “some text”}}
- {{bgcolor “<color>” “some text”}}
- {{colorattr “<attr>” “some text”}}
Available colors: black, red, green, yellow, blue, magenta, cyan, white Available attributes: bold, underline, invert (swaps the fg/bg colors)
Examples:
- {{color “red” “some text” | colorattr “bold” | bgcolor “blue”}}
- {{color “red”}} some text here {{resetcolor}}
You can also mix format tokens and/or data in the same line * {{color “cyan” “%E”}} {{color “blue” .KafkaClusterId}}
Notes:
- ‘color’ is just an alias of ‘fgcolor’
- calling ‘resetcolor’ will reset all color attributes, not just the most recently set
You can disable color output by passing the flag ‘–no-color’.
ccloud prompt [flags]
Flags¶
-f, --format string The format string to use. See the help for details. (default "({{color \"blue\" \"ccloud\"}}|{{color \"red\" \"%E\"}}:{{color \"cyan\" \"%K\"}})")
-g, --no-color Do not include ANSI color codes in the output.
-t, --timeout string The maximum execution time in milliseconds. (default "200ms")
Global Flags¶
-h, --help Show help for this command.
-v, --verbose count Increase verbosity (-v for warn, -vv for info, -vvv for debug, -vvvv for trace).
See Also¶
- Confluent Cloud CLI Command Reference - Confluent Cloud CLI.