How to change the colour of the cursor in RStudio terminal?

Viewed 288

I'm pretty annoyed that the colour of the cursor that indicates where you are in the terminal is black against a dark grey background when you use a dark theme. It's just hard to see where in the text you are, see example below:

enter image description here

I've tried to change this without succes. The theme I'm using is the Chaos theme, which is a standard theme that I think comes with every RStudio distribution. In the file linked above, I've tried changing the following (L191-L194) from this:

.terminal.xterm-cursor-style-block.focus:not(.xterm-cursor-blink-on) .terminal-cursor {
  background-color: #CCC;
  color: #1e1e1e;
}

to this:

.terminal.xterm-cursor-style-block.focus:not(.xterm-cursor-blink-on) .terminal-cursor {
  background-color: #CCC;
  color: #FCE94F;
}

After saving the edited file as chaos2.rsthemes and using the Tools > Global options > Appearance > Add... in RStudio to add the new document as a theme. I saw no change in the cursor colour after rebooting RStudio, whereas I had hoped it became yellow.

A related question talks about the mouse cursor instead of the text cursor I want to edit.

Does anyone know what the correct way to edit the theme is so I can have a light terminal cursor on a dark grey background? I don't want to change to a totally different theme, I just want this one small change.

1 Answers

Alright, I admit that it is quite tricky to achieve because the cursor colour is made of two elements one doesn't work without the other.

So what you need to add is .normal-mode .ace_cursor block in addition to .ace_cursor. Chaos theme has .ace_cursor only and changing the color value won't change anything.

In order to do that correctly, follow the steps below:

  1. Open RStudio and go to Tools > Global options > Appearance; and choose another theme, then close RStudio.

  2. Now you need to go to the themes folder

    Windows: Program Files > RStudio > resources > themes

    MacOS: Applications > RStudio > Contents > Resources > resources > themes

  3. Cut chaos.rstheme to your desktop and open it with Notepad or your favourite editor. (Don't forget to keep a backup)

  4. Find .ace_cursor block below

.ace_cursor {
  border-left: 2px solid #FFFFFF;
}

and replace it with these two blocks

.ace_cursor {
  color: #FCE94F;
}
.normal-mode .ace_cursor {
  background-color: #FCE94F;
}

and save the changes.

  1. Now open RStudio and go to Tools > Global options > Appearance, under Editor theme click Add and choose chaos.rstheme you edited on your Desktop.
  2. Click Apply and you should see the new cursor colour with the Chaos theme.
Related