https://github.com/overtrue/bash-color
Generate command line colorized text.
https://github.com/overtrue/bash-color
Last synced: 10 months ago
JSON representation
Generate command line colorized text.
- Host: GitHub
- URL: https://github.com/overtrue/bash-color
- Owner: overtrue
- License: mit
- Archived: true
- Created: 2015-07-20T09:55:04.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2019-04-06T08:05:55.000Z (almost 7 years ago)
- Last Synced: 2025-03-19T01:11:15.305Z (10 months ago)
- Language: PHP
- Size: 17.6 KB
- Stars: 12
- Watchers: 2
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BashColor
Generate command line colorized text. 给命令行文字添加前景/背景色、以及修饰效果。
[](https://travis-ci.org/overtrue/bash-color)
[](https://packagist.org/packages/overtrue/bash-color)
[](https://packagist.org/packages/overtrue/bash-color)
[](https://scrutinizer-ci.com/g/overtrue/bash-color/?branch=master)
[](https://scrutinizer-ci.com/g/overtrue/bash-color/?branch=master)
[](https://packagist.org/packages/overtrue/bash-color)
[](https://packagist.org/packages/overtrue/bash-color)
# Installing
```shell
$ composer require "overtrue/bash-color"
```
# Usage
```php
use Overtrue\BashColor\BashColor;
echo BashColor::render('Are you sure ?> [Y/n]:>'), "\n";
echo BashColor::render('hello world!>'), "\n";
echo BashColor::render('yes!>'), "\n";
echo BashColor::render('ugly!>'), "\n";
```
result:

### Attributes
- `fg` foreground color.
- `bg` background color.
- `opt` option.
### foreground
```
'default' // Default (usually green, white or light gray)
'black' // Black
'red' // Red (don't use with green background)
'green' // Green
'yellow' // Yellow
'blue' // Blue
'magenta' // Magenta/Purple
'purple' // Magenta/Purple
'cyan' // Cyan
'light_gray' // Light Gray
'dark_gray' // Dark Gray
'light_red' // Light Red
'light_green' // Light Green
'light_yellow' // Light Yellow
'light_blue' // Light Blue
'light_magenta' // Light Magenta/pink
'light_pink' // Light Magenta/pink
'light_cyan' // Light Cyan
'white' // White
```
### background
```
'default' // Default background color (usually black or blue)
'black' // Black
'red' // Red
'green' // Green
'yellow' // Yellow
'blue' // Blue
'magenta' // Magenta/Purple
'PURPLE' // Magenta/Purple
'cyan' // Cyan
'light_gray' // Light Gray (don't use with white foreground)
'dark_gray' // Dark Gray (don't use with black foreground)
'light_red' // Light Red
'light_green' // Light Green (don't use with white foreground)
'light_yellow' // Light Yellow (don't use with white foreground)
'light_blue' // Light Blue (don't use with light yellow foreground)
'light_magenta' // Light Magenta/Pink (don't use with light foreground)
'light_cyan' // Light Cyan (don't use with white foreground)
'white' // White (don't use with light foreground)
```
### options
```
'none' // Reset/Remove all option
'bold' // Bold/Bright
'bright' // Bold/Bright
'dim' // Dim
'underlined' // Underlined
'blink' // Blink
'reverse' // Reverse/invert
'invert' // Reverse/invert
'hidden' // Hidden
```
# Reference
[Bash tips: Colors and formatting](http://misc.flogisoft.com/bash/tip_colors_and_formatting)
## PHP 扩展包开发
> 想知道如何从零开始构建 PHP 扩展包?
>
> 请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— [《PHP 扩展包实战教程 - 从入门到发布》](https://learnku.com/courses/creating-package)
# License
MIT