Is there anyway to change console color from an echoed PHP statement in debian? I've got a script that runs from the command line of a debian sever and i'm trying to figure out view all the outputted information in a clearer fashion.
Asked
Active
Viewed 41 times
0
-
2Specifically the second answer, not the accepted answer – scrowler Feb 16 '16 at 23:24
-
https://wiki.archlinux.org/index.php/Bash/Prompt_customization – Feb 16 '16 at 23:25
-
@RobbieAverill Thank you, I found that one and tried the accepted answer wasn't working. – Patrick Pierson Feb 17 '16 at 00:02
1 Answers
2
Yes you can easily change the color of the output. That is, when the terminal supports it.
You can do this manually, as follows:
echo "\033[31m some colored text \033[0m some white text \n";
echo "\033[32m some colored text \033[0m some white text \n";
Or use a more sophisticated way with a library such as https://github.com/kevinlebrun/colors.php or https://github.com/abcarroll/simple-ansi-escape where you can have more understandable code, such as
echo $c('Hello World!')->white()->bold()->highlight('green') . PHP_EOL;
or
echo esc::ansiEscape(array('color/blue', 'faint', 'underline')), "I hope you enjoy Simple-Ansi-Escape!");
Hope that helps!

mark
- 344
- 3
- 8