(原+转)ubuntu终端输出彩色文字
生活随笔
收集整理的這篇文章主要介紹了
(原+转)ubuntu终端输出彩色文字
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
轉載請注明出處:
http://www.cnblogs.com/darkknightzh/p/6066697.html
參考網址:
http://www.tuicool.com/articles/jIbAjy
http://stackoverflow.com/questions/1718403/enable-bash-output-color-with-lua-script
?
C++中
std::cout << "\033[31m some string: " << num << "\033[0m";注意:貌似不恢復成默認顏色的話,后面的會一直是設置的顏色。
其中:
#define RESET "\033[0m" #define BLACK "\033[30m" /* Black */ #define RED "\033[31m" /* Red */ #define GREEN "\033[32m" /* Green */ #define YELLOW "\033[33m" /* Yellow */ #define BLUE "\033[34m" /* Blue */ #define MAGENTA "\033[35m" /* Magenta */ #define CYAN "\033[36m" /* Cyan */ #define WHITE "\033[37m" /* White */ #define BOLDBLACK "\033[1m\033[30m" /* Bold Black */ #define BOLDRED "\033[1m\033[31m" /* Bold Red */ #define BOLDGREEN "\033[1m\033[32m" /* Bold Green */ #define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */ #define BOLDBLUE "\033[1m\033[34m" /* Bold Blue */ #define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */ #define BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */ #define BOLDWHITE "\033[1m\033[37m" /* Bold White */?
torch中:
print(string.format("\27[31m str: %s", strval))注意:1. 其中\27為十進制的27,對應于8進制的033。
2. 貌似只對當前行有效。下一行還是默認顏色。
總結
以上是生活随笔為你收集整理的(原+转)ubuntu终端输出彩色文字的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: unity3D常见问题
- 下一篇: 《嵌入式C编程:PIC单片机和C编程技术