Respect $NO_COLOR environment variable

Close #1762
This commit is contained in:
Junegunn Choi 2024-05-20 10:50:00 +09:00
parent 04db44067d
commit aee417c46a
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
2 changed files with 9 additions and 2 deletions

View File

@ -482,7 +482,7 @@ color mappings.
.RS
.B BASE SCHEME:
(default: dark on 256-color terminal, otherwise 16)
(default: \fBdark\fR on 256-color terminal, otherwise \fB16\fR; If \fBNO_COLOR\fR is set, \fBbw\fR)
\fBdark \fRColor scheme for dark 256-color terminal
\fBlight \fRColor scheme for light 256-color terminal

View File

@ -481,6 +481,13 @@ func defaultPreviewOpts(command string) previewOpts {
}
func defaultOptions() *Options {
var theme *tui.ColorTheme
if os.Getenv("NO_COLOR") != "" {
theme = tui.NoColorTheme()
} else {
theme = tui.EmptyTheme()
}
return &Options{
Bash: false,
Zsh: false,
@ -502,7 +509,7 @@ func defaultOptions() *Options {
Multi: 0,
Ansi: false,
Mouse: true,
Theme: tui.EmptyTheme(),
Theme: theme,
Black: false,
Bold: true,
MinHeight: 10,