Ben
Ben

Reputation: 873

Emacs "stuck" colours in shell modes

Sometimes if I'm working in either a shell or eshell buffer with ansi-color-for-comint-mode on, and running a program which gives colourized output and then crashes while printing coloured text, the colour gets "stuck" and all subsequent text in that buffer is in that colour. The only way I've been able to fix it is to either turn ansi-color-for-comint-modeoff, or kill the shell buffer.

Is there a nicer way to tell a comint-derived shell buffer to "reset" the ansi colour codes?

Upvotes: 1

Views: 365

Answers (1)

Ben
Ben

Reputation: 873

It's not the prettiest solution, but this function works - it just sends the right color code to reset the colors

(defun unstick-ansi-color-codes ()
  (interactive)
  (end-of-buffer)
  (insert "echo -e \"\033[m\"")
  (comint-send-input nil t))

Upvotes: 5

Related Questions