comint-redirect-filter-functions is a variable defined in `comint.el'.
Its value is

  • This variable may be risky if used as a file-local variable.

List of functions to call before inserting redirected process output.
Each function gets one argument, a string containing the text received
from the subprocess. It should return the string to insert, perhaps
the same string that was received, or perhaps a modified or transformed

The functions on the list are called sequentially, and each one is given
the string returned by the previous one. The string returned by the
last function is the text that is actually inserted in the redirection buffer.

You can use `add-hook' to add functions to this list
either globally or locally.