pass grep --color=never

Knut Olav Bøhmer bohmer at gmail.com
Fri Oct 7 07:03:24 UTC 2022


Patch which respects "--color=auto"

On Fri, Oct 7, 2022 at 8:36 AM Knut Olav Bøhmer <bohmer at gmail.com> wrote:
>
> On Thu, Oct 6, 2022 at 6:55 PM Knut Olav Bøhmer <bohmer at gmail.com> wrote:
> >
> > On Thu, Oct 6, 2022 at 5:44 PM Tobias Girstmair <t-passwd at girst.at> wrote:
> > >
> > > On Thu, Oct 06, 2022 at 04:44:58PM +0200, Knut Olav Břhmer wrote:
> > > >Hi,
> > > >
> > > >I would like to enable output without color.
> > > >I also have on the wish list to print passfile_dir with a leading slash.
> > >
> > > i'm assuming you need this for passing pass' output to another program.
> > >
> > > how about using something like the code below. 'test -t' checks whether
> > > a file descriptor is a tty. this would keep interactive output the same,
> > > while automatically making pipelines work.
> > >
> > > if [[ -t 1 ]]
> > > then
> > >         color=always
> > > else
> > >         color=never
> > > fi
> > >
> > > # ...
> > >
> > > grepresults=$(... | grep --color="$color" ...)
> > >
> > >
> > > if that's too verbose for you:
> > >
> > > color=never
> > > test -t 1 && color=always
> >
> > consider this
> >
> > pass grep .| less -R
> >
> > Sometimes want colored output even if the output is a pipe. But I
> > would still consider your idea an improvement.
>
> test -t should be used if --color=auto
>
> --
> Knut Olav Bøhmer
> 41 000 108



-- 
Knut Olav Bøhmer
41 000 108
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Make-cmd_grep-understand-color.patch
Type: text/x-patch
Size: 1586 bytes
Desc: not available
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20221007/073eafff/attachment.bin>


More information about the Password-Store mailing list