From 37d277d13d138ed86d5b4d2f679d63852a6c6ffc Mon Sep 17 00:00:00 2001 From: Patrik Bartak Date: Thu, 27 Jun 2024 18:48:28 +0200 Subject: [PATCH] Add color flag in config Filter uses color if either the config flag or the command flag are set Make the flag false by default if no config exists --- cmd/util.go | 2 +- config/config.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/util.go b/cmd/util.go index 086cbdb..aa013db 100644 --- a/cmd/util.go +++ b/cmd/util.go @@ -55,7 +55,7 @@ func filter(options []string, tag string) (commands []string, err error) { t += tags snippetTexts[t] = s - if config.Flag.Color { + if config.Flag.Color || config.Conf.General.Color { t = fmt.Sprintf("[%s]: %s%s", color.HiRedString(s.Description), command, color.HiCyanString(tags)) } diff --git a/config/config.go b/config/config.go index a4a7bac..0ef553f 100644 --- a/config/config.go +++ b/config/config.go @@ -30,6 +30,7 @@ type GeneralConfig struct { SelectCmd string Backend string SortBy string + Color bool Cmd []string } @@ -123,6 +124,7 @@ func (cfg *Config) Load(file string) error { cfg.General.Column = 40 cfg.General.SelectCmd = "fzf --ansi --layout=reverse --border --height=90% --pointer=* --cycle --prompt=Snippets:" cfg.General.Backend = "gist" + cfg.General.Color = false cfg.Gist.FileName = "pet-snippet.toml"