Witam na mojej prywatnej stronie internetowej!
[If this is all Polish to you, click here: English]
Uwaga: z oczywistych powodów nie mogę zagwarantować swojej nieomylności, choć staram się o zgodność tego, co piszę, z Prawdą. Jest również oczywiste, że nie gwarantuję takiej zgodności w przypadku komentarzy. Umieszczenie linku do strony spoza niniejszego serwisu nie musi oznaczać, że podzielam poglądy autora tej strony, a jedynie, że uważam ją za wartościową z takich czy innych powodów.
Marcin ‘mbork’ Borkowski
Today I have a very short and rather niche tip, but maybe someone will find it useful (as I did). Like many other people, I use Magit on a daily basis. One thing that bothered me a bit was the fact that when I pressed $
to see the output of the Git process, all colors were gone. This was a problem for me, since the pre-commit hook I use calls the TypeScript compiler to tell me about any potential problems with types in my code. By default, the output of tsc
is colored with the ANSI color codes. While the coloring can be turned out, the setting to do that is rather crude (it also disables pretty-printing/formatting), and after all, these colors serve a purpose and are genuinely useful. I decided that before I turn the formatting off, it may be a good idea to check if Magit has an option to allow coloring the Git output using ANSI codes.
Well, the answer is yes and no. Indeed, there is a variable which does exactly that, but it is not a user option (that is, it is defined with defvar
and not defcustom
), and it is not even documented (that is, it has no docstring!). Still, it seems that it does its job, so from now I have
(setq magit-process-finish-apply-ansi-colors t)
in my init file.
I suppose that the reason it is not advertised may have something to do with performance issues. It is known that coloring with ANSI codes comes with a performance hit. For example, here is the docstring of the magit-log-color-graph-limit
option:
Number of commits over which log graphs are not colored. When showing more commits than specified, then the ‘--color’ argument is silently dropped. This is necessary because the ‘ansi-color’ library, which is used to turn control sequences into faces, is just too slow.
So if you want to turn magit-process-finish-apply-ansi-colors
on, be aware that it might slow down Magit. So far, I haven’t experienced that, but I’ve been only using it for a few days now, so we’ll have to see.