1

I just started using eshell. But the color support for some commands seems to be missing. For example I like to use the command exa, because of its nice colors. But in eshell it is all black.

3

For exa in eshell you can just use the following alias. It is preserved over a restart of Emacs.

alias exa *exa --color=always

The general problem to teach other programs about the color capabilities of the comint of Emacs is described on Rededit.

This approach helps for an example colorizing git output under Eshell.

Lax Citation:

Create a file ~/.terminfo/dumb-emacs-ansi.ti with the following content:

dumb-emacs-ansi|Emacs dumb terminal with ANSI color codes,
    am,
    colors#8, it#8, ncv#13, pairs#64,
    bold=\E[1m, cud1=^J, ht=^I, ind=^J, op=\E[39;49m,
    ritm=\E[23m, rmul=\E[24m, setab=\E[4%p1%dm,
    setaf=\E[3%p1%dm, sgr0=\E[m, sitm=\E[3m, smul=\E[4m,

Runs tic on that file. Set the environment variable TERM in Eshell to dumb-emacs-ansi.

The following Elisp code does that for you:

(setq comint-terminfo-terminal "dumb-emacs-ansi")

(let* ((terminfo-file (format "~/.terminfo/%s.ti" comint-terminfo-terminal))
       (default-directory (file-name-directory terminfo-file)))
  (unless (file-exists-p terminfo-file)
    (make-directory default-directory t)
    (with-temp-buffer
      (insert "dumb-emacs-ansi|Emacs dumb terminal with ANSI color codes,
    am,
    colors#8, it#8, ncv#13, pairs#64,
    bold=\\E[1m, cud1=^J, ht=^I, ind=^J, op=\\E[39;49m,
    ritm=\\E[23m, rmul=\\E[24m, setab=\\E[4%p1%dm,
    setaf=\\E[3%p1%dm, sgr0=\\E[m, sitm=\\E[3m, smul=\\E[4m,")
      (write-file terminfo-file)))
  (unless (file-exists-p (concat default-directory "d/" comint-terminfo-terminal))
    (start-process "*tic process*" "*Messages*" "tic" (expand-file-name terminfo-file))))

(add-hook 'eshell-mode-hook '(lambda ()
                   (setenv "TERM" comint-terminfo-terminal)))

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.