Reputation: 4531
In my php code I want to make console calls (e.g. 'git diff') via exec()
, or proc*
functions.
Is there any method to capture their output with colors?
Found a method: https://stackoverflow.com/a/35011507/2450729
Upvotes: 0
Views: 373
Reputation: 37038
You can ask git
to always color output:
git -c color.diff=always diff
Upvotes: 1
Reputation: 389
If you're using linux, you can use the tput setat command to highlight the output. Look this: http://linuxcommand.org/lc3_adv_tput.php
Upvotes: 0
Reputation: 4531
Found the way to do it.
There is no method to do it straight through php. But you can capture colorized output by wrapping your command with script -c <command>
tool. It will save colors.
Upvotes: 1