You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To help identify durations at a glance, `tj` maps durations to a color scale. The pre-defined templates `Color` and `ColorText` demonstrate this:
125
+
126
+
```bash
127
+
$ (echo fast;
128
+
sleep 1;
129
+
echo slower;
130
+
sleep 1.5;
131
+
echo slow;
132
+
sleep 2;
133
+
echo slowest) | tj -template Color
134
+
```
135
+

136
+
137
+
The terminal foreground color can be set by using `{{color .}}` in the output template. The default terminal color can be restored using `{{reset}}`.
138
+
139
+
The color scale can be set using the parameters `-scale`, `-scale-fast`, and `-scale-slow`:
140
+
141
+
- The `-scale` parameter defines the colors used in the scale.
142
+
- The `-scale-fast` and `-scale-slow` parameters define the boundaries of the scale: durations shorter than the value of `-scale-fast` are mapped to the leftmost color, durations longer than the value of `-scale-slow` are mapped to the rightmost color.
143
+
144
+
There are several pre-defined color scales:
145
+
146
+
| Name | Scale |
147
+
|---------------------|----------------------- |
148
+
| BlackToPurple |`#000 -> #F700FF`|
149
+
| BlackToRed |`#000 -> #F00`|
150
+
| BlueToRed |`#00F -> #F00`|
151
+
| CyanToRed |`#0FF -> #F00`|
152
+
| GreenToRed |`#0F0 -> #F00`|
153
+
| WhiteToPurple |`#FFF -> #F700FF`|
154
+
| WhiteToRed |`#FFF -> #F00`|
155
+
| WhiteToBlueToRed |`#FFF -> #00F -> #F00`|
156
+
157
+
You can also provide your own color scale using the same syntax as the pre-defined ones.
158
+
106
159
### Stopwatch regex
107
160
108
161
Sometimes you need to measure the duration between certain *tokens* in the input.
0 commit comments