From 046fbb860b753b8003b5c7aed3088e4f8e0a97de Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 17 Apr 2023 08:02:41 +0530 Subject: [PATCH] themes kitten: ignore custom theme files if they are stdout --- tools/themes/collection.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/themes/collection.go b/tools/themes/collection.go index 1676ad80a..c0e63d576 100644 --- a/tools/themes/collection.go +++ b/tools/themes/collection.go @@ -829,7 +829,18 @@ func (self *Themes) add_from_dir(dirpath string) error { } for _, e := range entries { if !e.IsDir() && strings.HasSuffix(e.Name(), ".conf") { - if _, err = self.AddFromFile(filepath.Join(dirpath, e.Name())); err != nil { + path := filepath.Join(dirpath, e.Name()) + // ignore files if they are the current processes, stdout + // allows using kitten theme --dump-theme > ~/.config/kitty/themes/name.conf + if st, err := os.Stat(path); err == nil { + if st2, err := os.Stdout.Stat(); err == nil && os.SameFile(st, st2) { + continue + } + } + if path == os.Stdout.Name() { + continue + } + if _, err = self.AddFromFile(path); err != nil { return err } }