git for-each-ref with a coloured format string

后端 未结 2 2058
情深已故
情深已故 2021-02-14 02:54

I\'m using git for-each-ref as a git alias to display a branch name and the subject of the last commit on that branch. That said, it\'s hard to tell where the branc

2条回答
  •  感动是毒
    2021-02-14 03:35

    I don't see anything in the for-each-ref man page that suggests it supports backslash-escape sequences like \033. If you replace \033 (and \e) with a literal escape character, it seems to work just fine.

    Cupcake says that for-each-ref also supports %xx hex escape sequences, which would look like:

    [alias]
        logbranch = "for-each-ref --sort=-committerdate refs/heads/ --format='[%1B[0;31m]%(refname:short)[%1B[m]   %(subject)' "
    

    This also works fine on my system.

提交回复
热议问题