eshell prompt displaying unix color codes when git ui = always
CsBigDataHub opened this issue · 2 comments
That setting tells Git to output ANSI escape sequences all the time even when the output is not the terminal, this is probably not you want, since it makes no sense to produce color outside the terminal.
If you have to keep color.ui = always
(but why?), you can remove the ANSI escape sequences using ansi-color.el
's ansi-color-apply
, for example,
(substring-no-properties
(ansi-color-apply (concat "\e[33m" "yellow" "\e[0m")))
;; => "yellow"
(epe-git-branch)
;; => "�[32mmaster�[m"
(substring-no-properties
(ansi-color-apply (epe-git-branch)))
;; => "master"
though ansi-color-apply
is not perfect, see https://emacs.stackexchange.com/questions/18457/stripping-stray-ansi-escape-sequences-from-eshell if performance is important.
If you have to keep
color.ui = always
(but why?)
@xuchunyang , Thanks.
Eshell was not producing colored output for commands like git status
. That was the reason why I have added that setting.
These settings below fixed this issue while keeping the prompt intact and I am able to produce colored output in eshell.
[color]
ui = auto
status = always
branch = auto
diff = always
grep = always
decorate = always
showbranch = always
interactive = always
see https://emacs.stackexchange.com/questions/18457/stripping-stray-ansi-escape-sequences-from-eshell if performance is important.
stackexachange solution also works even if I have color.ui = always
and color.branch = always
does stackexachange solution give better performance? Doesn't it have match the regex and nuke them after every output to display the prompt?