gopass/docs/commands/list.md
Yolan Romailler d56639fcd7
[CLEANUP] Migration of options to more appropriate sections (#2681)
* [CLEANUP] Moving options to the correct config section

This adds an easy migration path to our config handling, which should
allow us to migrate option names around much more easily in the future.

Any system level config or env variables options are not migrated.

This also fixes a bug in our test code, where the root mount path was
not properly set in our config, because we used "path:" instead of
"path=" to set it.

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>

* [DOCUMENTATION] Document legacy options and their migration path

This also makes sure that legacy options aren't used in the code anymore using the docs test and its regexp

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>

* [n/a] Removing weird spaces from changelog

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>

* [DOCUMENTATION] Reformatting our Markdown tables properly

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>

* [TESTING] Patching a timezone bug in tests

This is a fun one where if your Timezone isn't UTC and you are past midnight but it's not past midnight UTC, the tests would fail because you're not using the right date to validate it.

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>

* [n/a] Fix a typo and use the correct Env variables in the doc about the custom Env variables

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>

* [BREAKING] Custom Env options moved from GOPASS_CONFIG_CONFIG_KEY_i to GOPASS_CONFIG_KEY_i

As discussed in #2617, this actually reflects the way GIT_CONFIG works.

It also fixes a potential Panic in our codebase when IsSet was called
without any Preset config on a non-existing key.

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>

* [CLEANUP] Patching all of the new linter complaints

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>

* [CLEANUP] Use Go1.21 everywhere

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>

* [n/a] Increase our Golangci timeout

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>

* [n/a] code review comment and extra regression test

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>

---------

Signed-off-by: Yolan Romailler <anomalroil@users.noreply.github.com>
2023-11-03 18:40:58 +01:00

3.9 KiB

list command

The list command is used to list all the entries in the password store or at a given prefix.

Synopsis

gopass ls
gopass ls path/to/entries
  • List all the entries in the password store including the one in mounted stores: gopass list
  • List all the entries in a given folder showing their relative path from the root: gopass list path/to/entries

Note: list will not change anything, nor encrypt or decrypt anything.

Flags

Flag Aliases Description
--limit value -l value Max tree depth (default: -1)
--flat -f Print a flat list of secrets (default: false)
--folders -d Print a flat list of folders (default: false)
--strip-prefix -s Strip prefix from filtered entries (default: false)

The --flat and --folders flags provide a plaintext list of the entries located at the given prefix (default prefix being the root /). They are notably used to produce the completion results. The --flat one will list all entries, one per line, using its full path. The --folders one will display all the folders, one per line, recursively per level. For instance an entry folder/sub/entry would cause it to list both:

$ gopass list --folders
folder
folder/sub

whereas gopass list --flat would have just displayed one line: folder/sub/entry.

The --strip-prefix flag is meant to be used along with --flat or --folders. It will list the relative path from the current prefix, removing the said prefix, instead of listing the relative paths from the root. For instance on entry folder/sub/entry, running gopass ls -f -s folder would display only sub/entry instead of folder/sub/entry.

The --limit flag starts counting its depth from the root store, which means that a depth of 0 only lists the items in the root gopass store:

$ gopass list -l 0
gopass
├── bar/
├── foo/
└── test (/home/user/.local/share/gopass/stores/substore1)

A value of 1 would list all the items in the root, plus their sub-items but no more:

$ gopass list -l 1
gopass
├── bar/
│   └── bar
├── foo/
│   ├── bar
│   └── foo
└── test (/home/user/.local/share/gopass/stores/substore1)
    └── foo

A negative value lists all the items without any depth limit.

$ gopass list -l -1
gopass
├── bar/
│   └── bar
├── foo/
│   ├── bar/
│   │   ├── bar/
│   │   │   └── bar
│   │   └── baz
│   └── foo
└── test (/home/user/.local/share/gopass/stores/substore1)
    └── foo

The flags can be used together: gopass -l 1 -d will list only the folders up to a depth of 1:

$ gopass list -l 1 -d
bar/
foo/
foo/bar/
test/
test/foo/

Shadowing

It is possible to have a path that is both an entry and a folder. In that case the list command will display the folder with a marker of (shadowed), it can still be accessed using gopass show path/to/it, while the content of the folder can be listed using gopass list path/to/it.

It should also be noted that the mount command can completely "shadow" an entry in a password store, simply by having the same name and this entry and its subentries will not be visible using ls anymore until the substore is unmounted. The entries shadowed by a mount will not show up in a search and cannot be accessed at all without unmounting.

For instance in our example above, maybe there is an entry test/zaz in the root store, but since the substore is mounted as test/, it only displays the content of the substore. Unmounting it reveals its shadowed entries:

$ gopass list test
test/ 
└── foo
$ gopass mounts rm test
$ gopass list test
test/ 
└── zaz