From 1c5a6a508704b20cc9982ee2186b4d8ac9e5ed85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl-Einar=20Bergstr=C3=B8m?= Date: Wed, 14 Oct 2026 16:43:27 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20lazysecrets=20list's=20note=20mark=20is?= =?UTF-8?q?=20a=20Nerd=20Font=20note,=20=E2=9C=8E=20without=20icons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/lazysecrets/list.go | 10 ++++++---- cmd/lazysecrets/list_test.go | 8 ++++++-- internal/ui/icons/icons.go | 2 ++ 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cmd/lazysecrets/list.go b/cmd/lazysecrets/list.go index 8cef3d9..9f5f7c6 100644 --- a/cmd/lazysecrets/list.go +++ b/cmd/lazysecrets/list.go @@ -1,6 +1,7 @@ package main import ( + "cmp" "context" "encoding/json" "errors" @@ -51,7 +52,7 @@ func listCmd(providers []provider.Provider, st *store.Store, cachePath string, t iconsOn := fs.Bool("icons", withIcons, "put the provider's Nerd Font icon before names (text)") stars := fs.Bool("stars", true, "put ★ before starred names, in the theme's favouriteColor (text)") recent := fs.Bool("recent", withRecent, "put ◷ before names used lately, in mutedColor (text; default ui.recentIcon)") - notes := fs.Bool("notes", true, "put ✎ before names with a note, in mutedColor (text; the note is printed either way)") + notes := fs.Bool("notes", true, "put a note icon (✎ without --icons) before names with a note, in mutedColor (text; the note is printed either way)") expiry := fs.Bool("expiry", true, "mark and say which have expired (✗ expired) or expire within ui.expiryWarningDays (⚠ expires in 12d) (text)") kinds := fs.String("kind", "", "only these kinds, comma-separated: "+strings.Join(listing.Kinds, ", ")+" (vault: also scopes and repo files)") showErrors := fs.Bool("errors", true, "list the lists that can't be read, with why (text: ✗ lines; json: \"error\")") @@ -194,8 +195,9 @@ func nameOf(e listing.Entry, theme styles.Styles, color bool) string { // marks says what goes before the name, in a field of its own so a // search leaves it out: ✗ in red when something's wrong (it couldn't be // read, or has expired) or ⚠ when it expires within warn; ★ for a starred -// entry and ◷ for one used lately, as the TUI marks them; ✎ for one with a -// note; then the provider's icon. The marks are right-aligned in room for every kind +// entry and ◷ for one used lately, as the TUI marks them; a note icon +// (✎ without Nerd Font icons) for one with a note; then the provider's +// icon. The marks are right-aligned in room for every kind // turned on, so they sit by the icon and names line up. type marks struct { theme styles.Styles @@ -231,7 +233,7 @@ func (m marks) of(e listing.Entry) string { mark(e.Recent, m.theme.Muted, "◷") } if m.notes { - mark(e.Note != "", m.theme.Muted, "✎") + mark(e.Note != "", m.theme.Muted, cmp.Or(m.icons.Note, "✎")) } pad := strings.Repeat(" ", room-len(parts)) // each mark and its space kind := provider.Kind("") diff --git a/cmd/lazysecrets/list_test.go b/cmd/lazysecrets/list_test.go index 7056460..ba322c2 100644 --- a/cmd/lazysecrets/list_test.go +++ b/cmd/lazysecrets/list_test.go @@ -94,14 +94,18 @@ func TestListNoteMark(t *testing.T) { e listing.Entry want string }{ - {listing.Entry{Provider: "azure", Note: "rotate in May"}, " ✎ " + az}, - {listing.Entry{Provider: "azure", Note: "x", Starred: true}, " ★ ✎ " + az}, + {listing.Entry{Provider: "azure", Note: "rotate in May"}, " " + icons.NerdFont.Note + " " + az}, + {listing.Entry{Provider: "azure", Note: "x", Starred: true}, " ★ " + icons.NerdFont.Note + " " + az}, {listing.Entry{Provider: "azure"}, " " + az}, } { if got := m.of(c.e); got != c.want { t.Errorf("%+v: %q, want %q", c.e, got, c.want) } } + m.icons = icons.None // without Nerd Font icons + if got := m.of(listing.Entry{Provider: "azure", Note: "x"}); got != " ✎" { + t.Errorf("no icons: %q", got) + } } func TestListStatusMark(t *testing.T) { diff --git a/internal/ui/icons/icons.go b/internal/ui/icons/icons.go index c726da4..15a3941 100644 --- a/internal/ui/icons/icons.go +++ b/internal/ui/icons/icons.go @@ -11,6 +11,7 @@ type Set struct { Repo string Encrypted string // an encrypted file (SOPS) PlainFile string // a plain text secrets file (.env) + Note string // has a note (lazysecrets list) } // None renders no icons. @@ -24,6 +25,7 @@ var NerdFont = Set{ Repo: "\U000F02A2", // md-git Encrypted: "\U000F033E", // md-lock PlainFile: "\U000F0214", // md-file + Note: "\U000F09ED", } // Prefix returns the icon for kind followed by a space, or "" if the set has