Giter VIP home page Giter VIP logo

bash-color's Introduction

BashColor

Generate command line colorized text. 给命令行文字添加前景/背景色、以及修饰效果。

Build Status Latest Stable Version Latest Unstable Version Code Coverage Scrutinizer Code Quality Total Downloads License

Installing

$ composer require "overtrue/bash-color"

Usage

use Overtrue\BashColor\BashColor;

echo BashColor::render('<fg=green>Are you sure ?</><fg=yellow> [Y/n]:</>'), "\n";
echo BashColor::render('<bg=purple;>hello world!</>'), "\n";
echo BashColor::render('<fg=green;opt=bold>yes!</>'), "\n";
echo BashColor::render('<fg=cyan;opt=bold;bg=red>ugly!</>'), "\n";

result:

qq20150822-1 2x

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

PHP 扩展包开发

想知道如何从零开始构建 PHP 扩展包?

请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— 《PHP 扩展包实战教程 - 从入门到发布》

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.