Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-detect color based on TERM #591

Open
rchl opened this issue Dec 1, 2023 · 1 comment
Open

Auto-detect color based on TERM #591

rchl opened this issue Dec 1, 2023 · 1 comment
Labels
feature request A new lefthook feature description

Comments

@rchl
Copy link

rchl commented Dec 1, 2023

⚡ 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.

@rchl rchl added the feature request A new lefthook feature description label Dec 1, 2023
@hahuang65
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A new lefthook feature description
Projects
None yet
Development

No branches or pull requests

2 participants