Skip to content

Commit 640a897

Browse files
committed
feat: assign default prefix colors matching turborepo's palette
Change the default prefix color from 'reset' (no color) to 'auto', so that each command gets a distinct color out of the box. Set ACCEPTABLE_CONSOLE_COLORS to turborepo's 5-color palette (cyan, magenta, green, yellow, blue) which cycles on repeat. This list only controls what 'auto' picks from — manually specified colors (via --prefix-colors) are unrestricted and accept any valid Chalk color name, hex value, or modifier.
1 parent 7e6f9e7 commit 640a897

File tree

5 files changed

+18
-31
lines changed

5 files changed

+18
-31
lines changed

docs/cli/prefixing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ $ concurrently --prefix '{index}-{pid}' 'echo Hello there' 'echo General Kenobi!
5656

5757
## Prefix Colors
5858

59-
By default, there are no colors applied to concurrently prefixes, and they just use whatever the terminal's defaults are.
59+
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).
6060

6161
This can be changed by using the `--prefix-colors`/`-c` flag, which takes a comma-separated list of colors to use.<br/>
62-
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.
62+
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.
6363

6464
```bash
6565
$ concurrently -c red,blue 'echo Hello there' 'echo General Kenobi!'

lib/defaults.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const prefix = '';
3535
* Default prefix color.
3636
* @see https://www.npmjs.com/package/chalk
3737
*/
38-
export const prefixColors = 'reset';
38+
export const prefixColors = 'auto';
3939

4040
/**
4141
* How many bytes we'll show on the command prefix.

lib/logger.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ export class Logger {
166166
color = modifiedColor;
167167
}
168168
} else {
169-
const defaultColor = getChalkPath(this.chalk, defaults.prefixColors) as ChalkInstance;
169+
const defaultColor =
170+
getChalkPath(this.chalk, defaults.prefixColors) ?? this.chalk.reset;
170171
color = getChalkPath(this.chalk, command.prefixColor ?? '') ?? defaultColor;
171172
}
172173
return color(text);

lib/prefix-color-selector.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ describe('#ACCEPTABLE_CONSOLE_COLORS', () => {
181181
expect(PrefixColorSelector.ACCEPTABLE_CONSOLE_COLORS.length).toBeGreaterThan(1);
182182
});
183183

184-
it('uses the same color order as turborepo', () => {
184+
it('uses the same colors and order as turborepo', () => {
185185
expect(PrefixColorSelector.ACCEPTABLE_CONSOLE_COLORS).toEqual([
186186
'cyan',
187187
'magenta',

lib/prefix-color-selector.ts

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -63,33 +63,19 @@ export class PrefixColorSelector {
6363
this.colorGenerator = createColorGenerator(normalizedColors);
6464
}
6565

66-
/** A list of colors that are readable in a terminal. */
66+
/**
67+
* Colors used by `auto` selection and default cycling.
68+
*
69+
* Matches turborepo's palette: cyan, magenta, green, yellow, blue.
70+
* These are visually distinct on both dark and light terminal backgrounds
71+
* without carrying semantic meaning (unlike red → errors) or blending
72+
* into the default text color (unlike white/grey).
73+
*
74+
* This list does NOT restrict manually specified colors — any valid Chalk
75+
* color name, hex value, or modifier can be passed via `--prefix-colors`.
76+
*/
6777
public static get ACCEPTABLE_CONSOLE_COLORS() {
68-
// Colors picked randomly, can be amended if required
69-
return [
70-
// Prevent duplicates, in case the list becomes significantly large
71-
...new Set<keyof ChalkInstance>([
72-
// Text colors
73-
'cyan',
74-
'yellow',
75-
'greenBright',
76-
'blueBright',
77-
'magentaBright',
78-
'white',
79-
'grey',
80-
'red',
81-
82-
// Background colors
83-
'bgCyan',
84-
'bgYellow',
85-
'bgGreenBright',
86-
'bgBlueBright',
87-
'bgMagenta',
88-
'bgWhiteBright',
89-
'bgGrey',
90-
'bgRed',
91-
]),
92-
];
78+
return [...new Set<keyof ChalkInstance>(['cyan', 'magenta', 'green', 'yellow', 'blue'])];
9379
}
9480

9581
/**

0 commit comments

Comments
 (0)