Custom colored console prompt using crayon

241 views Asked by At

In R I can create a custom console prompt via:

options(prompt = "foo> ")

And I can use the crayon package to make it a certain color:

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

However, in RStudio, color changes never take effect until the prompt is inactive; i.e. until I hit enter and the current line is replaced with a new prompt.

Like this:

enter image description here

The current console prompt is always yellow. Once I hit enter, a new yellow prompt appears and the previous line moves up and is colored blue.

I do not see this behavior when running R from the command line, the prompt immediately turns blue:

enter image description here

Is there a way around this in RStudio using crayon, or is RStudio short-circuiting the prompt formatting in a way that makes it impossible to fix without a change to the RStudio IDE (meaning I should report a bug/feature request with them)?

0

There are 0 answers