Reputation: 7435
I'm currently using git
to deploy a project, and I was wondering how I could get the output of tools like npm
and gulp
to be in color in the same that they are when using those tools locally?
For example
vs
Upvotes: 4
Views: 1955
Reputation: 1966
For those using nodejs based projects, it seems colored output issues with git hooks are a consequence of git running hooks without "tty" support by default.
This cause some tools to consider the terminal does not supports colors.
For instance, as discussed here https://github.com/okonet/lint-staged/issues/693
If you are using node based tools, you may fix your issue by adding export FORCE_COLOR=1
in your hook script. This will fix all tools based on this library : https://www.npmjs.com/package/supports-color
Upvotes: 1
Reputation: 1336
On your remote server
type in
git config --global color.ui auto
That should give you color
Upvotes: 2
Reputation: 17455
The short answer: either force colored output for each tool used in git hooks on the remote side or forcibly set TERM
environment variable (again, on the remote side). Use export TERM=xterm
(or export TERM=xterm-color
) somewhere in the beginning of each hook script.
The long answer: by default unix tools like npm
or git
itself generate colored output (i.e. output with extra escape-sequences which change color accordingly) only if these tools can detect that terminal in which they operate is capable to change colors. Terminal capabilities is defined via environment variable TERM
. Ordinary, interactive SSH sessions can transfer TERM
value to a remote side (see Can I forward env variables over ssh?) but non-interactive sessions usually don't do this, non-interactive sessions may operate in TTY-less mode. You can force usage of color for a particular tool (e.g. npm via config) or configure TERM environment variable properly.
Upvotes: 2