Customize the Colors in Help Output
When you run a command with the --help or -h flag, the help output uses colors to highlight certain parts, such as command and flag descriptions, executable name, and more. If you don’t like the default colors, you can customize them.
-
Create a file called
theme.jsonusing your favorite editor. -
Add key-value pairs to the
theme.jsonfile where the key specifies the help section you want to colorize and the value is a color.You can use chalk-style colors (such as
greenBright), hex code (#FF0000), or RGB (rgb(255,255,255)). See the defaulttheme.jsonfile for an example.Here’s the list of available JSON keys and what they colorize:
alias: The aliases that are listed in the ALIASES section.bin:Thesfexecutable name.command: The command’s name.commandSummary: The command’s summary.dollarSign: The$character printed before examples and command usage.flag: The long and short flag names.flagDefaultValue: The text[default: X]that is displayed for flags that have a default value.flagOptions: The valid options for a flag.flagRequired: The text(required)that is displayed for required flags.flagSeparator: The,character (comma) that separates the short and long flag names.sectionDescription: The text inside the sections, such as all the text in the DESCRIPTION section.sectionHeader: The section header, such as DESCRIPTION.topic: The topics listed in the TOPICS section.version: The VERSION section that’s displayed when you runsf --help. To configure a section’s color back to the default black, set the associated JSON key tonone.
-
Save the
theme.jsonfile in the appropriate directoryThe directory where you save the file depends on your operating system.
- Linux and macOS:
$HOME/.config/sf - Windows: Depending on your Salesforce CLI configuration, either
C:\Users\<username>\.config\sfor%LOCALAPPDATA%\sf
- Linux and macOS:
When you next run a command with the --help or -h flag, the help output uses your customized colors.
As an example, here’s the internal theme.json file that Salesforce CLI uses to configure the default help output colors.