{"id":18581935,"url":"https://github.com/coder/pretty","last_synced_at":"2025-04-10T11:35:43.625Z","repository":{"id":192907137,"uuid":"687553871","full_name":"coder/pretty","owner":"coder","description":"TTY styles for Go","archived":false,"fork":false,"pushed_at":"2023-09-08T20:59:47.000Z","size":40,"stargazers_count":14,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T22:35:30.206Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-09-05T15:36:32.000Z","updated_at":"2025-02-16T02:57:53.000Z","dependencies_parsed_at":"2023-09-05T22:45:21.551Z","dependency_job_id":null,"html_url":"https://github.com/coder/pretty","commit_stats":null,"previous_names":["coder/pretty"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fpretty","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fpretty/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fpretty/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coder%2Fpretty/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coder","download_url":"https://codeload.github.com/coder/pretty/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248208688,"owners_count":21065205,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T00:08:26.960Z","updated_at":"2025-04-10T11:35:38.580Z","avatar_url":"https://github.com/coder.png","language":"Go","readme":"# pretty\n[![Go Reference](https://pkg.go.dev/badge/github.com/coder/pretty.svg)](https://pkg.go.dev/github.com/coder/pretty)\n\n\n`pretty` is a performant Terminal pretty printer for Go. We built it after\nusing lipgloss and experiencing significant performance issues.\n\n`pretty` doesn't implement escape sequences and should be used alongside [termenv](https://pkg.go.dev/github.com/muesli/termenv).\n\n\n## Basic Usage\n\n```go\nerrorStyle := pretty.Style{\n\t\tpretty.FgColor(termenv.RGBColor(\"#ff0000\")),\n\t\tpretty.BgColor(termenv.RGBColor(\"#000000\")),\n\t\tpretty.WrapCSI(termenv.BoldSeq),\n}\n\nerrorStyle.Printf(\"something bad\")\n```\n\n## Color\n\nYou can use `termenv` to adapt the colors to the terminal's color palette:\n\n```go\nprofile := termenv.NewOutput(os.Stdout, termenv.WithColorCache(true)).ColorProfile()\nerrorStyle := pretty.Style{\n        pretty.FgColor(profile.Color(\"#ff0000\")),\n        pretty.BgColor(profile.Color(\"#000000\")),\n        pretty.WrapCSI(termenv.BoldSeq),\n}\n```\n\n## Performance\n\n```\n$ go test -bench=.\ngoos: darwin\ngoarch: arm64\npkg: github.com/coder/pretty/bench\nBenchmarkPretty-10               5142177               232.6 ns/op        55.88 MB/s         272 B/op          8 allocs/op\nBenchmarkLipgloss-10              280276              4157 ns/op           3.13 MB/s         896 B/op         72 allocs/op\nPASS\nok      github.com/coder/pretty/bench   2.921s\n```\n\npretty remains fast even through dozens of transformations due to its linked-list\nbased intermediate representation of text. In general, operations scale with\nthe number of links rather than the length of the text. For example, coloring\na 1000 character string green is just as fast as wrapping a 1 character string.\n\nEventually we could reap even more gains by replacing the linked-list with a\nrope.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoder%2Fpretty","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoder%2Fpretty","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoder%2Fpretty/lists"}