{"id":17136883,"url":"https://github.com/weirdpattern/color-host","last_synced_at":"2025-03-24T06:43:05.297Z","repository":{"id":85355983,"uuid":"96145178","full_name":"weirdpattern/color-host","owner":"weirdpattern","description":"A PowerShell module to write colorful outputs","archived":false,"fork":false,"pushed_at":"2017-07-19T04:05:15.000Z","size":25,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-29T12:24:50.757Z","etag":null,"topics":["ansi","console","host","output","powershell","powershell-module","powershell-script","vt100","write","write-host"],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weirdpattern.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-03T19:45:04.000Z","updated_at":"2019-09-25T07:11:52.000Z","dependencies_parsed_at":"2023-03-13T03:16:58.210Z","dependency_job_id":null,"html_url":"https://github.com/weirdpattern/color-host","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weirdpattern%2Fcolor-host","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weirdpattern%2Fcolor-host/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weirdpattern%2Fcolor-host/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weirdpattern%2Fcolor-host/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weirdpattern","download_url":"https://codeload.github.com/weirdpattern/color-host/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245223980,"owners_count":20580362,"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":["ansi","console","host","output","powershell","powershell-module","powershell-script","vt100","write","write-host"],"created_at":"2024-10-14T20:05:38.183Z","updated_at":"2025-03-24T06:43:05.276Z","avatar_url":"https://github.com/weirdpattern.png","language":"PowerShell","readme":"# ColorHost\nA PowerShell module to write colorful messages to a host.\n\n## TL;DR;\n__ColorHost__ lets you format messages you output to the host. With __ColorHost__ you can say goodbye to the thousands of lines of code needed to format a simple message.  \n\nConsider this output message:   \n![Output](https://user-images.githubusercontent.com/19519411/27975613-a083675a-6328-11e7-9490-f6ec4ed51795.png)\n\nTo get this, you need these lines of code:\n```powershell\nWrite-Host \"ColorHost \" -ForegroundColor Green -NoNewLine\nWrite-Host \"lets you write colorful \" -NoNewLine\nWrite-Host \"messages\" -ForegroundColor Red\n```\n\n__ColorHost__ converts that into this:\n```powershell\nWrite-ColorHost \"$[32mColorHost$[0m lets you write colorful $[31mmessages$[0m\"\n```\n\n## Installation\nUsing PSGet\n```powershell\nInstall-Module ColorHost\n```\n\nAlternatively you can do a manual installation\n1. Download `src/*` from [http://github.com/weirdpattern/color-host](http://github.com/weirdpattern/color-host)\n2. Copy all files to your modules folder (e.g. `Modules\\ColorHost\\`)\n3. Execute `Import-Module ColorHost` (or add this to your profile)\n4. Enjoy!\n\n## Usage\nThe module can be used in two different ways.\n\n### As a regular cmdlet\n\n```powershell\nWrite-ColorHost\n    [[-Objects] \u003cObject[]\u003e]\n    [-NoNewLine]\n    [-Separator \u003cObject\u003e]\n    [-ForegroundColor { ConsoleColor | string }]\n    [-BackgroundColor { ConsoleColor | string }]\n    [\u003c\\CommonParameters\\\u003e]\n```\n\n### As part of the pipeline\n\n```powershell\nObject | Write-ColorHost\n           [-NoNewLine]\n           [-Separator \u003cObject\u003e]\n           [-ForegroundColor { ConsoleColor | string }]\n           [-BackgroundColor { ConsoleColor | string }]\n           [\u003c\\CommonParameters\\\u003e]\n```\n\nNote: __ColorHost__ is 100% compatible with __Write-Host__, in fact, both functions behave the same way and produce exactly the same outputs. Please refer to \n[Write-Host](https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.utility/write-host) documentation for a detail description on how objects are processed.\n\n## ANSI Color Codes\nDue to limitations imposed by _PowerShell_ (not a lot of output processing options other than 16 bit foreground and background colors for now, hopefully this will change in the near future with the introduction of _Bash on Windows_ 10 and newer versions of _PowerShell_), __ColorHost__ supports only a subset of all valid _ANSI color codes_.  \n\n### Escape characters\n_ANSI color codes_ require the `\u003cESC\u003e` character to be processed. In _Bash_, and other scripting languages, this character can be represented in several ways:  \n- `\\e`\n- `\\033`\n- `\\x1B`\n\n__ColorHost__ supports all of them plus the character `$` (sooner or later you will realize the character `$` is extensively used in _PowerShell_, so why not support it?).  \n\n### Formatting\n__ColorHost__ supports the following control sequences:\n\n__Reset__\n\n| Code | Description          | Example                             |\n| :--: | -------------------- | ----------------------------------- |\n| 0    | Reset all attributes | `Write-ColorHost \"$[0mNormal text\"` |\n\n__Foreground__\n\n| Code | Description              | Example                                     | Equivalent                                                                 |\n| :--: | ------------------------ | ------------------------------------------- | -------------------------------------------------------------------------- |\n| 39   | Default foreground color | `Write-ColorHost \"$[39mNormal text\"`        | `Write-Host \"Normal text\" -ForegroundColor $HOST.UI.RawUI.ForegroundColor` |\n| 30   | Black                    | `Write-ColorHost \"$[30mBlack text\"`         | `Write-Host \"Normal text\" -ForegroundColor Black`                          |\n| 31   | Red                      | `Write-ColorHost \"$[31mRed text\"`           | `Write-Host \"Normal text\" -ForegroundColor DarkRed`                        |\n| 32   | Green                    | `Write-ColorHost \"$[32mGreen text\"`         | `Write-Host \"Normal text\" -ForegroundColor DarkGreen`                      |\n| 33   | Yellow                   | `Write-ColorHost \"$[33mYellow text\"`        | `Write-Host \"Normal text\" -ForegroundColor DarkYellow`                     |\n| 34   | Blue                     | `Write-ColorHost \"$[34mBlue text\"`          | `Write-Host \"Normal text\" -ForegroundColor DarkBlue`                       | \n| 35   | Magenta                  | `Write-ColorHost \"$[35mMagenta text\"`       | `Write-Host \"Normal text\" -ForegroundColor DarkMagenta`                    |\n| 36   | Cyan                     | `Write-ColorHost \"$[36mCyan text\"`          | `Write-Host \"Normal text\" -ForegroundColor DarkCyan`                       |\n| 37   | Light Gray               | `Write-ColorHost \"$[37mLight Gray text\"`    | `Write-Host \"Normal text\" -ForegroundColor Gray`                           |\n| 90   | Dark Gray                | `Write-ColorHost \"$[90mDark Gray text\"`     | `Write-Host \"Normal text\" -ForegroundColor DarkGray`                       |\n| 91   | Light Red                | `Write-ColorHost \"$[91mLight Red text\"`     | `Write-Host \"Normal text\" -ForegroundColor Red`                            |\n| 92   | Light Green              | `Write-ColorHost \"$[92mLight Green text\"`   | `Write-Host \"Normal text\" -ForegroundColor Green`                          |\n| 93   | Light Yellow             | `Write-ColorHost \"$[93mLight Yellow text\"`  | `Write-Host \"Normal text\" -ForegroundColor Yellow`                         |\n| 94   | Light Blue               | `Write-ColorHost \"$[94mLight Blue text\"`    | `Write-Host \"Normal text\" -ForegroundColor Blue`                           |\n| 95   | Light Magenta            | `Write-ColorHost \"$[95mLight Magenta text\"` | `Write-Host \"Normal text\" -ForegroundColor Magenta`                        |\n| 96   | Light Cyan               | `Write-ColorHost \"$[96mLight Cyan text\"`    | `Write-Host \"Normal text\" -ForegroundColor Cyan`                           |\n| 97   | White                    | `Write-ColorHost \"$[97mWhite text\"`         | `Write-Host \"Normal text\" -ForegroundColor White`                          |\n\n__Background__\n\n| Code | Description              | Example                                      | Equivalent                                                                 |\n| :--: | ------------------------ | -------------------------------------------- | -------------------------------------------------------------------------- |\n| 49   | Default background color | `Write-ColorHost \"$[49mNormal text\"`         | `Write-Host \"Normal text\" -BackgroundColor $HOST.UI.RawUI.BackgroundColor` |\n| 40   | Black                    | `Write-ColorHost \"$[40mBlack text\"`          | `Write-Host \"Normal text\" -BackgroundColor Black`                          |\n| 41   | Red                      | `Write-ColorHost \"$[41mRed text\"`            | `Write-Host \"Normal text\" -BackgroundColor DarkRed`                        |\n| 42   | Green                    | `Write-ColorHost \"$[42mGreen text\"`          | `Write-Host \"Normal text\" -BackgroundColor DarkGreen`                      |\n| 43   | Yellow                   | `Write-ColorHost \"$[43mYellow text\"`         | `Write-Host \"Normal text\" -BackgroundColor DarkYellow`                     |\n| 44   | Blue                     | `Write-ColorHost \"$[44mBlue text\"`           | `Write-Host \"Normal text\" -BackgroundColor DarkBlue`                       | \n| 45   | Magenta                  | `Write-ColorHost \"$[45mMagenta text\"`        | `Write-Host \"Normal text\" -BackgroundColor DarkMagenta`                    |\n| 46   | Cyan                     | `Write-ColorHost \"$[46mCyan text\"`           | `Write-Host \"Normal text\" -BackgroundColor DarkCyan`                       |\n| 47   | Light Gray               | `Write-ColorHost \"$[47mLight Gray text\"`     | `Write-Host \"Normal text\" -BackgroundColor Gray`                           |\n| 100  | Dark Gray                | `Write-ColorHost \"$[100mDark Gray text\"`     | `Write-Host \"Normal text\" -BackgroundColor DarkGray`                       |\n| 101  | Light Red                | `Write-ColorHost \"$[101mLight Red text\"`     | `Write-Host \"Normal text\" -BackgroundColor Red`                            |\n| 102  | Light Green              | `Write-ColorHost \"$[102mLight Green text\"`   | `Write-Host \"Normal text\" -BackgroundColor Green`                          |\n| 103  | Light Yellow             | `Write-ColorHost \"$[103mLight Yellow text\"`  | `Write-Host \"Normal text\" -BackgroundColor Yellow`                         |\n| 104  | Light Blue               | `Write-ColorHost \"$[104mLight Blue text\"`    | `Write-Host \"Normal text\" -BackgroundColor Blue`                           |\n| 105  | Light Magenta            | `Write-ColorHost \"$[105mLight Magenta text\"` | `Write-Host \"Normal text\" -BackgroundColor Magenta`                        |\n| 106  | Light Cyan               | `Write-ColorHost \"$[106mLight Cyan text\"`    | `Write-Host \"Normal text\" -BackgroundColor Cyan`                           |\n| 107  | White                    | `Write-ColorHost \"$[107mWhite text\"`         | `Write-Host \"Normal text\" -BackgroundColor White`                          |\n\nSequences can be combined using `;`, e.g. `Write-ColorHost $[31;42mOK$[0m` will output the 'OK' in red on a green background.\n\n## License\nMIT © Patricio Trevino\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweirdpattern%2Fcolor-host","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweirdpattern%2Fcolor-host","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweirdpattern%2Fcolor-host/lists"}