pass grep --color=never

Knut Olav Bøhmer bohmer at gmail.com
Thu Oct 6 16:55:14 UTC 2022


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.

Regards
-- 
Knut Olav Bøhmer


More information about the Password-Store mailing list