Auto-detect `color` based on TERM
rchl opened this issue · comments
⚡ Summary
It would be nice to have an "auto" value (or similar) for the colors
option so that colors are automatically toggled based on the terminal's support for escape sequences.
I don't know that much about terminals to suggest the BEST solution here but I would think that there is some convention that programs use for detecting whether the terminal supports colors. For example using the TERM
or COLORTERM
env variables. For example my zsh terminal reports:
COLORTERM=truecolor
TERM=xterm-256color
while my git software that doesn't support escape sequences reports:
TERM=dumb
Value
Since the hooks are invoked by git, it's currently not possible to vary the color
state based on whether the hooks run from a dumb or color-supporting terminal. So to avoid hard-to-read text, one has to disable colors in all cases.
Behavior and configuration changes
The color
option could support 'auto'
string value.
Would love this. lefthook
gets run in vim-fugitive
and prints out color codes. It would be nice to auto-detect non-interactive terminals and disable color.
Currently I have to disable color everywhere if I want readable output in vim
.