Force “git status” to output color on the terminal (inside a script)

后端 未结 3 501
面向向阳花
面向向阳花 2020-12-02 10:00

EDIT:

I would like to make a recommendation that parsing colors is a generally ill-conceived idea.

Part of why i wanted it was so I can both parse it and pas

3条回答
  •  猫巷女王i
    2020-12-02 10:06

    EDIT:

    I would like to make a strong recommendation that parsing colors is a generally ill-conceived idea.

    Part of why i wanted it was so I can both parse it and pass it along in my own script output. This is... okay, but it would probably be saner to use porcelain or some such and re-build the colored parts myself!

    Original answer follows.


    I keep finding answers really quickly after asking questions. Something to do with thinking about a problem long enough to write it out that you formulate better approaches for solving it. Anyway, the solution to this is just

    git config color.status always
    

    I imagine that a general purpose solution involves expect or something pty related to force any programs that require it into thinking they are on a terminal.

提交回复
热议问题