Detect TTY (interactive status): +[[ -t 1 ]] && YES_TTY=1 If NO_TTY, use find + sed as suggested, else keep the existing "Tree" command: - tree -C -l --noreport "$PREFIX/$path" | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' # remove .gpg at end of line, but keep colors + if [[ -z $YES_TTY ]] ; then + find "$PREFIX/$path" -type f -iname \*.gpg | sed -e 's/\.gpg$//g' -e "s,^$PREFIX,,g" -e 's/^\///g' # when non-interactive (pipeline) print full-path-per-entry (for easy copy/paste or filtering) + else + tree -C -l --noreport "$PREFIX/$path" | tail -n +2 | sed -E 's/\.gpg(\x1B\[[0-9]+m)?( ->|$)/\1\2/g' # remove .gpg at end of line, but keep colors + fi
...@Dacoda... yep, "naive find" was what I came up with in 2019. Other password managers change behaviour slightly when running in a TTY/NO_TTY context: https://github.com/lastpass/lastpass-cli/blob/2a70884ed7ef48a8d621687acb96202cc354245b/cmd-ls.c#L287-L288 It's _crucial_ to support `pass ls | grep ...` and be able to show the full identifier for usage. --Robert On Wednesday, April 14, 2021, 08:20:36 AM PDT, Dacoda Strack <[email protected]> wrote: On Wed, Apr 14, 2021 at 04:01:50PM +0300, Greg Minshall wrote: > Pierre, > > > I am willing to write a patch if we find consensus. > > i'd be a fan. and, if highlighting could somehow also be controlled, > that would be great. > > cheers, Greg This sounds great to me, I wonder if something naive like find $PASSWORD_STORE -type f -name '*.gpg' with some additional sed to clean up the path would get us where we need to be I think I'm going to have a small local fork and build RPMs with some of these minor patches.
0001-Print-full-paths-in-pipeline-non-interactive-usage.patch
Description: Binary data
