Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/cli/prefixing.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ $ concurrently --prefix '{index}-{pid}' 'echo Hello there' 'echo General Kenobi!

## Prefix Colors

By default, there are no colors applied to concurrently prefixes, and they just use whatever the terminal's defaults are.
By default, concurrently automatically assigns colors to each command's prefix, cycling through `cyan`, `magenta`, `green`, `yellow`, and `blue` (the same palette and order used by turborepo).

This can be changed by using the `--prefix-colors`/`-c` flag, which takes a comma-separated list of colors to use.<br/>
The available values are color names (e.g. `green`, `magenta`, `gray`, etc), a hex value (such as `#23de43`), or `auto`, to automatically select a color.
The available values are color names (e.g. `green`, `magenta`, `gray`, etc), a hex value (such as `#23de43`), `auto` to automatically select a color, or `reset` to disable coloring.

```bash
$ concurrently -c red,blue 'echo Hello there' 'echo General Kenobi!'
Expand Down
2 changes: 1 addition & 1 deletion lib/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const prefix = '';
* Default prefix color.
* @see https://www.npmjs.com/package/chalk
*/
export const prefixColors = 'reset';
export const prefixColors = 'auto';

/**
* How many bytes we'll show on the command prefix.
Expand Down
3 changes: 2 additions & 1 deletion lib/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ export class Logger {
color = modifiedColor;
}
} else {
const defaultColor = getChalkPath(this.chalk, defaults.prefixColors) as ChalkInstance;
const defaultColor =
getChalkPath(this.chalk, defaults.prefixColors) ?? this.chalk.reset;
color = getChalkPath(this.chalk, command.prefixColor ?? '') ?? defaultColor;
}
return color(text);
Expand Down
10 changes: 10 additions & 0 deletions lib/prefix-color-selector.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,14 @@ describe('#ACCEPTABLE_CONSOLE_COLORS', () => {
// always has more than one entry, which is what we enforce via this test
expect(PrefixColorSelector.ACCEPTABLE_CONSOLE_COLORS.length).toBeGreaterThan(1);
});

it('only includes colors that are visually distinct, semantically neutral, and lightweight', () => {
expect(PrefixColorSelector.ACCEPTABLE_CONSOLE_COLORS).toEqual([
'cyan',
'magenta',
'green',
'yellow',
'blue',
]);
});
});
38 changes: 12 additions & 26 deletions lib/prefix-color-selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,33 +63,19 @@ export class PrefixColorSelector {
this.colorGenerator = createColorGenerator(normalizedColors);
}

/** A list of colors that are readable in a terminal. */
/**
* Colors used by `auto` selection and default cycling.
*
* Each color is chosen to be visually distinct on both dark and light
* terminal backgrounds, without carrying semantic meaning (e.g. red
* implies errors) or blending into default text (e.g. white/grey).
* Background colors are excluded to keep output lightweight.
*
* This list does NOT restrict manually specified colors — any valid Chalk
* color name, hex value, or modifier can be passed via `--prefix-colors`.
*/
public static get ACCEPTABLE_CONSOLE_COLORS() {
// Colors picked randomly, can be amended if required
return [
// Prevent duplicates, in case the list becomes significantly large
...new Set<keyof ChalkInstance>([
// Text colors
'cyan',
'yellow',
'greenBright',
'blueBright',
'magentaBright',
'white',
'grey',
'red',

// Background colors
'bgCyan',
'bgYellow',
'bgGreenBright',
'bgBlueBright',
'bgMagenta',
'bgWhiteBright',
'bgGrey',
'bgRed',
]),
];
return [...new Set<keyof ChalkInstance>(['cyan', 'magenta', 'green', 'yellow', 'blue'])];
}

/**
Expand Down