-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Description
Describe the feature or problem you’d like to solve
I haven't been able to use the --template
functions of autocolor
or color
to colorize a template output.
Particularly, I want to be able to modify the table output of gh issue list
and keep the issue labels colorized, without having to manually map hex colors to ANSI strings, particularly because the hex color is already stored in the JSON output i.e. gh issue list --json labels
Example: gh issue list
If I wanted to remove the updated field, I might try:
gh issue list --json number,title,labels --template '{{range .}}{{printf "#%.0f %s" .number .title}}{{if .labels}} {{range $i, $label := .labels}}{{if $i}}, {{end}}{{printf "%s" $label.name}}{{end}}{{end}}{{"\n"}}{{end}}'
Naturally since color
and autocolor
only support ANSI strings like 'Red', 'Green', etc, adding | color $label.color
fails to print the label colors.
Proposed solution
-
Add an example to
gh help formatting
that shows how a user can create a template to print issue labels with their corresponding colors.- Here is an example where
hexcolor
could be replaced with syntax to handle applying the label color.
- Here is an example where
gh issue list --json labels --template \
'{{range .}}{{printf "%s" | hexcolor .color}}{{end}}'
- This would help users apply their own filters i.e. using
--jq
,-S
, while still viewing an output similar togh issue list
.
Additional context
Here is some information I found about how to apply colors in zsh, but I haven't been able to figure out how to apply this so that I can color my label output.