Custom prompt color with crayon

I'm running R 3.6.1, RStudio 1.2.5019 on macOS 10.14.3

I can set a custom console prompt as usual with

options(prompt = "foo> ")

However, if I try to use the crayon package to set a custom prompt with special formatting, RStudio only applies the formatting after I hit enter to non-active prompts. The current prompt with the cursor always retains the standard color/formatting. So,

options(prompt = crayon::blue("foo> ")

results in this:

Screen Shot 2020-04-06 at 9.07.53 AM

The current prompt will always be yellow, but will turn blue once I hit enter.

This is not the case when I set the same custom prompt running R from the command line:

Screen Shot 2020-04-06 at 2.17.47 PM

In this case, the prompt is immediately styled correctly.

I'm guessing that RStudio is intercepting the evaluation at some point. If possible, it would be nice to adjust how RStudio is handling this case so that custom prompts can be styled with the crayon package.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.