feat: lazysecrets list prints the account, and open and get take it (--account)

This commit is contained in:
keb committed 2026-10-14 21:24:01 +02:00
1 parent 1f330bc619
commit b05d19209c
9 files changed
+118 -43

No files matched your search

+33 -21
View File
@@ -138,26 +138,39 @@ a newline only on a terminal.
### Listing, for fzf and pickers
`lazysecrets list` prints every source, vault and secret, one per line:
its kind (`source`, `vault`, `secret`, `key` or `certificate`), its name
(`platform-prod / kv-app-prod / db-password`) and its link,
tab-separated. It's what Go to searches, so fzf, or an editor's picker,
can search it instead, showing the names and acting on the links:
`lazysecrets list` prints every source, vault and secret, one per line,
tab-separated:
| Field | |
|---|---|
| kind | `source`, `vault`, `secret`, `key` or `certificate` |
| name | `platform-prod / kv-app-prod / db-password` |
| account | what it's listed through: an az account (`Azure:<user>/<tenant>`), `Databricks` or `Repos` |
| link | its `lazysecrets://` link |
It's what Go to searches, so fzf, or an editor's picker, can search it
instead, showing the names and acting on the links:
```sh
lazysecrets list | fzf --ansi --with-nth='2..-2' --accept-nth=-1 \
--bind 'ctrl-o:become(lazysecrets open {-1})' \
--bind 'ctrl-y:execute-silent(lazysecrets get {-1} | pbcopy)'
lazysecrets list | fzf --ansi --with-nth='2..-3' --accept-nth=-1 \
--bind 'ctrl-o:become(lazysecrets open --account {-2} {-1})' \
--bind 'ctrl-y:execute-silent(lazysecrets get --account {-2} {-1} | pbcopy)'
```
`--with-nth='2..-2'` shows and searches the names, leaving out the kind,
the first field, and the link, the last; `{-1}` and `--accept-nth=-1` are
the link. The kind is one word and the link has no spaces, so this works
without `--delimiter`. To filter by kind yourself: `awk -F'\t' '$1 == "secret"'`. `enter` prints
it (`lazysecrets get $(…)`), `ctrl-o` opens it in lazysecrets and `ctrl-y`
copies the value (`pbcopy` on macOS; `wl-copy` or `xclip` on Linux). A
value copied this way isn't cleared from the clipboard after
`values.clipboardClear`, as one copied in lazysecrets is.
`--with-nth='2..-3'` shows and searches only the names; `{-1}` and
`--accept-nth=-1` are the link, `{-2}` the account. All but the name are
one word, so this works without `--delimiter`. To filter by kind
yourself: `awk -F'\t' '$1 == "secret"'`.
`enter` prints the link (`lazysecrets get $(…)`), `ctrl-o` opens it in
lazysecrets and `ctrl-y` copies the value (`pbcopy` on macOS; `wl-copy` or
`xclip` on Linux). A value copied this way isn't cleared from the
clipboard after `values.clipboardClear`, as one copied in lazysecrets is.
`--account` makes `open` and `get` use the account it was listed through,
when several of yours can see it: without, `open` asks which, and `get`
tries the one that last read it first. The link stays as it is, to copy
and share; the account isn't part of it.
What's [cached](config.md#cache) prints at once. Then, like Go to, it loads
what's missing or older than `--max-age` (2m), and what's new in it follows
@@ -183,15 +196,14 @@ shows the colours with `--ansi`. `--color never` leaves them out, for
scripts, and `--icons=false` the icons. The link is never coloured.
`--format json` prints an object per line instead, for editor plugins,
without colours or icons, with each entry's kind, and `error` on a list
it couldn't read:
without colours or icons, and with `error` on a list it couldn't read:
```json
{"link":"lazysecrets://azure/kv-app-prod.vault.azure.net/secrets/db-password","kind":"secret","provider":"azure","path":["platform-prod","kv-app-prod","db-password"],"account":"alice"}
{"link":"lazysecrets://azure/kv-app-prod.vault.azure.net/secrets/db-password","kind":"secret","provider":"azure","path":["platform-prod","kv-app-prod","db-password"],"account":"Azure:alice@example.com/<tenant>","accountLabel":"alice"}
```
`account` is there when several az accounts are signed in. Values are never
listed.
`accountLabel`, the account's short name, is there when several az
accounts are signed in. Values are never listed.
## From the browser and chat