shell - force git status to output color on the terminal (inside a script) -
i see color because scripting robust enough (so far) handle color codes. seem i'm going against grain here, don't see big deal having parse stuff escape codes in scripts. if colors interactive use, why wouldn't in script use might aggregating data , crunching more data manually? wouldn't colors even more important?
anyway, have neat little shell script wrote munges git status
output, , i'm looking make script keep colors intact. global git config set lists of changed , untracked files show in color in git status. unfortunately unlike git diff
there no option forcing color git status
can find.
to abundantly clear, issue:
$ git status
produces perfect output, (excerpt script follows)
git status | sed "s/^#/\x1b[34m#[0m/"
produces no colored git status
output, , can see here i'm explicitly converting leading hash-characters blue because helps highlight different regions of output script.
does know how put out colors? there maybe standard program can use can used "fake terminal" stdin/stdout pipe? in fact working on pty pseudoterminal tool make use of purpose, it's rather heavy-handed solution (and not ready use yet haven't finished building it).
to avoid changing git config, can current command passing config variable -c
:
git -c color.status=always status | less -rex
that variable status
command only. diff
, show
, log
variable color.ui
:
git -c color.ui=always diff | less -rex
note -c
must become before status
or diff
argument, , not after.
Comments
Post a Comment