I can't seem to identify this color sequence. I have enabled ansi colors successfully (to test, ls shows colored output), however a strange thing happens when I attempt to run npm and I can't identify the kind of colors these are, or how to make it so eshell can show them. The output is as follows

Usage npm <command>
... <remainder of usage here>
npm @ 3.3.10 /usr/lib/node_modules/npm
^[[?25h^[[0G^[[?25h^[[0G~/my/directory/that/i/am/in $

I have tried to look for things like "non-ansi color codes" and "npm color codes" and none of them have pointed me in the correct direction.

Can anyone identify these colors and help me figure out how to display them properly?



I have identified these as unicode sequences. I have added everything in:


as well as the following code for Eshell specifically:

(defun set-buffer-utf8 ()
   (set-buffer-process-coding-system 'utf-8 'utf-8)
 (add-hook 'eshell-mode-hook 'set-buffer-utf8)

This does not work. I have also tried this with the modes utf-16 and mule-utf-8 with no luck.

Also, if I type

echo $LANG I get en_US.UTF-8. echo $LC_ALL also returns en_US.UTF-8.


I have now tried to set the encoding of eshell (in the hook above) to iso-8859-7 and iso-8859-1 with no luck.

  • These are most certainly not related to colors.
    – wasamasa
    Nov 27 '15 at 22:38
  • I have seen it uses some kind of utf symbols to show the branches and sub-dependencies. It may be the character selection jointly with the color. Is your terminal utf-8? Nov 28 '15 at 11:24
  • @DiegoSevilla This is EShell so im not actually sure.
    – Steve
    Nov 28 '15 at 17:00
  • @DiegoSevilla I have added the stuff specified here: masteringemacs.org/article/working-coding-systems-unicode-emacs and it has not fixed it.
    – Steve
    Nov 28 '15 at 17:29
  • This is not encoding-related either.
    – wasamasa
    Dec 16 '15 at 8:35

There's a huge amount of ANSI escape sequences. I've made a regex catching most you'll run into based on this answer and wrote some code to use it with eshell:

(defvar my-ansi-escape-re
  (rx (or ?\233 (and ?\e ?\[))
      (zero-or-more (char (?0 . ?\?)))
      (zero-or-more (char ?\s ?- ?\/))
      (char (?@ . ?~))))

(defun my-nuke-ansi-escapes (beg end)
    (goto-char beg)
    (while (re-search-forward my-ansi-escape-re end t)
      (replace-match ""))))

(defun my-eshell-nuke-ansi-escapes ()
  (my-nuke-ansi-escapes eshell-last-output-start eshell-last-output-end))

(add-hook 'eshell-output-filter-functions 'my-eshell-nuke-ansi-escapes t)
  • Interesting, thank you! I noticed you said it is not encoding related. Could you elaborate?
    – Steve
    Dec 20 '15 at 18:22
  • Given the lack of mojibake and the presence of sequences suspiciously looking like ANSI escapes, I am fairly sure this is not a problem to solve by changing the buffer encoding and investigated Emacs' ANSI escape support instead.
    – wasamasa
    Dec 21 '15 at 0:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.