{"id":21643424,"url":"https://github.com/questocat/console-color","last_synced_at":"2025-04-11T18:21:20.707Z","repository":{"id":56977195,"uuid":"96324734","full_name":"questocat/console-color","owner":"questocat","description":"🎨 A simple command line colorize library","archived":false,"fork":false,"pushed_at":"2018-06-01T00:44:23.000Z","size":129,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T00:04:32.882Z","etag":null,"topics":["bash","bash-color","cli-color","color","console-color"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/questocat.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}},"created_at":"2017-07-05T13:53:34.000Z","updated_at":"2023-02-10T21:22:23.000Z","dependencies_parsed_at":"2022-08-21T07:40:37.252Z","dependency_job_id":null,"html_url":"https://github.com/questocat/console-color","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/questocat%2Fconsole-color","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/questocat%2Fconsole-color/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/questocat%2Fconsole-color/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/questocat%2Fconsole-color/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/questocat","download_url":"https://codeload.github.com/questocat/console-color/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248456385,"owners_count":21106606,"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":["bash","bash-color","cli-color","color","console-color"],"created_at":"2024-11-25T05:34:18.393Z","updated_at":"2025-04-11T18:21:20.684Z","avatar_url":"https://github.com/questocat.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## console-color\n\nA simple command line colorize library\n\n[![StyleCI](https://styleci.io/repos/96324734/shield?branch=master)](https://styleci.io/repos/96324734)\n[![Build Status](https://scrutinizer-ci.com/g/questocat/console-color/badges/build.png?b=master)](https://scrutinizer-ci.com/g/emanci/console-color/build-status/master)\n[![Code Coverage](https://scrutinizer-ci.com/g/questocat/console-color/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/emanci/console-color/?branch=master)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/questocat/console-color/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/emanci/console-color/?branch=master)\n[![Packagist](https://img.shields.io/packagist/l/doctrine/orm.svg)](https://packagist.org/packages/questocat/console-color)\n\n## Installation\n\nUsing [Composer](https://getcomposer.org) to add the package to your project's dependencies:\n\n```bash\ncomposer require questocat/console-color\n```\n\n## Usage\n\n```php\n$consoleColor = new ConsoleColor();\n\n// 字体色渲染\n$consoleColor-\u003ered('红色字体');\n$consoleColor-\u003ered()-\u003erender('红色字体');\n$consoleColor-\u003eblue('蓝色字体');\n$consoleColor-\u003eblue()-\u003erender('蓝色字体');\n\n// 背景色渲染\n$consoleColor-\u003eredBackground('红色背景');\n$consoleColor-\u003eredBackground()-\u003erender('红色背景');\n$consoleColor-\u003eblueBackground('蓝色背景');\n$consoleColor-\u003eblueBackground()-\u003erender('蓝色背景');\n\n// 控制序列渲染\n$consoleColor-\u003ebold('粗体文字');\n$consoleColor-\u003eunderline('带下划线的文字');\n$consoleColor-\u003eunderline()-\u003erender('带下划线的文字');\n\n// 内置主题渲染\n$consoleColor-\u003einfo('输出提示信息');\n$consoleColor-\u003eerror('输出错误信息');\n$consoleColor-\u003ewarning('输出警告信息');\n$consoleColor-\u003esuccess('输出成功信息');\n\n// 添加自定义颜色\n$consoleColor-\u003eaddColor('fooBar', 94);              // 添加单个颜色\n$consoleColor-\u003efooBar('自定义颜色字体，单个属性');\n$consoleColor-\u003eaddColor('fooBar', [1, 4, 41, 92]);  // 添加单个颜色\n$consoleColor-\u003efooBar('自定义颜色字体，含多个属性');\n$consoleColor-\u003eaddColor(['foo' =\u003e [38, 5, 5, 48, 5, 3], 'bar' =\u003e [48, 5, 28]]);  // 添加多个颜色（256）\n$consoleColor-\u003efoo('自定义颜色字体，含多个属性');\n$consoleColor-\u003efoo()-\u003ebar('自定义颜色字体，含多个属性');\n\n// 支持 88/256 Colors\n$consoleColor-\u003ecolor256(12)-\u003erender('8/256 字体');             // 字体颜色\n$consoleColor-\u003ecolor256(12, FOREGROUND)-\u003erender('8/256 字体'); // 字体颜色\n$consoleColor-\u003ecolor256(25, BACKGROUND)-\u003erender('8/256 背景'); // 背景颜色\n\n// 组合渲染\n$consoleColor-\u003eblueBackground()-\u003ered('蓝色背景，红色字体');\n$consoleColor-\u003ered()-\u003eblueBackground()-\u003erender('蓝色背景，红色字体，其他组合方式');\n$consoleColor-\u003eblue()-\u003eyellowBackground()-\u003ered()-\u003erender('黄色背景，红色字体');\n$consoleColor-\u003ecolor256(6)-\u003eyellowBackground()-\u003erender('8/256 字体，黄色背景');\n$consoleColor-\u003ered()-\u003ecolor256(60, BACKGROUND)-\u003erender('8/256 背景，红色字体');\n```\n\nExample will output\n\n\u003cimg src=\"https://github.com/questocat/console-color/blob/master/colors.png\" width = \"260\" alt=\"example-output\" align=center /\u003e\n\n#### Colors/Formats Api\n\n| Foreground    | Background              | Formats    |  Themes    |\n|---------------|-------------------------|------------|------------|\n| default       | defaultBackground       | bold       | info       |\n| black         | blackBackground         | dim        | warning    |\n| red           | redBackground           | underline  | error      |\n| green         | greenBackground         | blink      | success    |\n| yellow        | yellowBackground        | invert     |            |\n| blue          | blueBackground          | hidden     |            |\n| magenta       | magentaBackground       |            |            |\n| cyan          | cyanBackground          |            |            |\n| lightGray     | lightGrayBackground     |            |            |\n| darkGray      | darkGrayBackground      |            |            |\n| lightRed      | lightRedBackground      |            |            |\n| lightGreen    | lightGreenBackground    |            |            |\n| lightYellow   | lightYellowBackground   |            |            |\n| lightBlue     | lightBlueBackground     |            |            |\n| lightMagenta  | lightMagentaBackground  |            |            |\n| lightCyan     | lightCyanBackground     |            |            |\n| white         | whiteBackground         |            |            |\n\n## Reference\n\n* [bash:tip_colors_and_formatting](http://misc.flogisoft.com/bash/tip_colors_and_formatting#colors2)\n* [Wiki-Bash/Prompt_customization#Colors](https://wiki.archlinux.org/index.php/Bash/Prompt_customization#Colors)\n* [Wiki-ANSI_escape_code#Colors](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors)\n\n## License\n\nLicensed under the [MIT license](https://github.com/questocat/console-color/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquestocat%2Fconsole-color","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquestocat%2Fconsole-color","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquestocat%2Fconsole-color/lists"}