In the terminal, (set-cursor-color "red")
has no effect, so the only way I can distinguish insert from normal mode under evil-mode is through the <N>
or <I>
on the modeline. Is there a way to set the cursor colour even in text terminals? (I use sakura with TERM=xterm-256color
if that matters.)
Here's a hack that seems to work:
(defun evil-set-cursor-including-terminal (orig-fn specs)
(if (display-graphic-p)
(funcall orig-fn specs)
(when (= (display-color-cells) 256) ; otherwise messes up tmux under xfce4-terminal
(pcase specs
((and (or `(,colour) `(,colour . ,shape))
(guard (stringp colour)))
(send-string-to-terminal (concat "\033]12;" colour "\007")))))))
(advice-add #'evil-set-cursor :around #'evil-set-cursor-including-terminal)
The exception is replace-state, which doesn't seem to change back to the normal colour (so I have to insert/visual and exit to get back normal colour).