docs/cli/prefixing.md
concurrently will by default prefix each command's outputs with a zero-based index, wrapped in square brackets:
$ concurrently 'echo Hello there' "echo 'General Kenobi!'"
[0] Hello there
[1] General Kenobi!
[0] echo Hello there exited with code 0
[1] echo 'General Kenobi!' exited with code 0
If you've given the commands names, they are used instead:
$ concurrently --names one,two 'echo Hello there' "echo 'General Kenobi!'"
[one] Hello there
[two] General Kenobi!
[one] echo Hello there exited with code 0
[two] echo 'General Kenobi!' exited with code 0
There are other prefix styles available too:
| Style | Description |
|---|---|
index | Zero-based command's index |
name | The command's name |
command | The command's line |
time | Time of output |
pid | ID of the command's process (PID) |
none | No prefix |
Any of these can be used by setting the --prefix/-p flag. For example:
$ concurrently --prefix pid 'echo Hello there' 'echo General Kenobi!'
[2222] Hello there
[2223] General Kenobi!
[2222] echo Hello there exited with code 0
[2223] echo 'General Kenobi!' exited with code 0
It's also possible to have a prefix based on a template. Any of the styles listed above can be used by wrapping it in {}.
Doing so will also remove the square brackets:
$ concurrently --prefix '{index}-{pid}' 'echo Hello there' 'echo General Kenobi!'
0-2222 Hello there
1-2223 General Kenobi!
0-2222 echo Hello there exited with code 0
1-2223 echo 'General Kenobi!' exited with code 0
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.
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.
$ concurrently -c red,blue 'echo Hello there' 'echo General Kenobi!'
blackbluecyangreengraymagentaredwhiteyellowColors can take modifiers too. Several can be applied at once by appending .<modifier 1>.<modifier 2> and so on.
$ concurrently -c '#23de43.inverse,bold.blue.dim' 'echo Hello there' 'echo General Kenobi!'
resetbolddimhiddeninverseitalicstrikethroughunderlineA background color can be set in a similarly fashion.
$ concurrently -c bgGray,red.bgBlack 'echo Hello there' 'echo General Kenobi!'
bgBlackbgBluebgCyanbgGreenbgGraybgMagentabgRedbgWhitebgYellowconcurrently supports all Chalk color functions:
| Function | Description |
|---|---|
#RRGGBB | Foreground hex (shorthand) |
bg#RRGGBB | Background hex (shorthand) |
hex(#RRGGBB) | Foreground hex |
bgHex(#RRGGBB) | Background hex |
rgb(R,G,B) | Foreground RGB (0-255) |
bgRgb(R,G,B) | Background RGB (0-255) |
ansi256(N) | Foreground ANSI 256 (0-255) |
bgAnsi256(N) | Background ANSI 256 (0-255) |
All functions can be chained with colors and modifiers:
# Hex colors
$ concurrently -c 'bg#FF0000.bold,black.bgHex(#00FF00).dim' 'echo Red bg' 'echo Green bg'
# RGB colors
$ concurrently -c 'rgb(255,136,0).bold,black.bgRgb(100,100,255)' 'echo Orange' 'echo Blue bg'
# ANSI 256 colors
$ concurrently -c 'ansi256(199),ansi256(50).bgAnsi256(17)' 'echo Pink' 'echo Cyan on blue'
By default, the entire prefix is colored. When using a template, you can restrict coloring to a specific region by wrapping it with the {color} and {/color} markers — anything outside the markers is rendered without color.
$ concurrently -c red,blue --prefix '[{color}{name}{/color}] {pid}' --names one,two 'echo Hello there' 'echo General Kenobi!'
In the example above, only one and two are colored — the surrounding brackets and the PID stay in the terminal's default color.
If only one of the markers is present, the missing side is implicit: an {color} without a matching {/color} colors everything from the opener to the end of the prefix, and a {/color} without a preceding {color} colors everything from the start of the prefix up to the closer. A template with neither marker is colored in full, matching the previous behavior.
When using the command prefix style, it's possible that it'll be too long.
It can be limited by setting the --prefix-length/-l flag:
$ concurrently -p command -l 10 'echo Hello there' 'echo General Kenobi!'
[echo..here] Hello there
[echo..bi!'] General Kenobi!
[echo..here] echo Hello there exited with code 0
[echo..bi!'] echo 'General Kenobi!' exited with code 0
It's also possible that some prefixes are too short, and you want all of them to have the same length.
This can be done by setting the --pad-prefix flag:
$ concurrently -n foo,barbaz --pad-prefix 'echo Hello there' 'echo General Kenobi!'
[foo ] Hello there
[foo ] echo Hello there exited with code 0
[barbaz] General Kenobi!
[barbaz] echo 'General Kenobi!' exited with code 0
[!NOTE] If using the
pidprefix style in combination with--restart-tries, the length of the PID might grow, in which case all subsequent lines will match the new length.
This might happen, for example, if the PID was 99 and it's now 100.