Accept arguments in lieu of STDIN
Perhaps accept arguments, so it can be called like:
cmdcolor \033[31m RED ON DEFAULT
This could be useful from batch scripts.
Sure, I'll look into this. However, for now, the same can be accomplished with the following:
IF [%1] == [PIPE] (
SHIFT
) ELSE (
CALL %0 PIPE %* | cmdcolor
GOTO :EOF
)
This makes the script pipe itself through cmdcolor, so any echo beyond that will be colored.
Thanks for considering it.
Yes, that is an alternative. However, it has a slightly different effect: the colour persists until manually reset. To achieve the same effect as running the command for each line, it would be necessary to reset to the default at the end of each echo.
Currently, I'm using echo text | cmdcolor. This is definitely more of a nice-to-have - it would make scripts tidier.