I'm trying to change the color of my cursor inside Emacs to another color dynamically.
I'm using emacs -nw
for the terminal Emacs. The terminal I'm using is Rxvt-Unicode (Urxvt).
Since Emacs can't (I think) make changes to the terminal, (set-cursor-color "red")
won't work. In order to change the cursor color of the terminal I can run
echo -ne '\033]12;red\007'
. This changes the color of the cursor to red.
What I tried to do in Emacs is to run this command inside it.
M-x shell-command RET echo -ne '\033]12;red\007' RET
However, Emacs will escape the echoed string and print it at the bottom of the window, and not actually make any changes to the cursor.
I really don't know what else I can do from here, I don't want to use the Emacs GUI. Does anyone know a way around this? I want to be able to change the color of my cursor depending on my current mode, which is why it needs to be dynamic. If anyone has any other suggestions I would be happy to hear them!
I think you want to use send-string-to-terminal
.
E.g. (send-string-to-terminal "\033]12;red\007")
.