Can I extract arbitrary lines to stdout, rather than to the clipboard?

Kjetil Torgrim Homme kjetil.homme at redpill-linpro.com
Sun Jun 28 21:33:46 CEST 2020


On 28/06/2020 20.54, yvh11a wrote:
> Hello everyone, nice to meet you all.
> 
> Assuming I have secrets stored in zx2c4.com as follows:
> 
>      hunter2
>      my-email at example.com
> 
> I can do the following:
> 
>      pass -c zx2c4.com    -> sends hunter2 to clipboard
>      pass -c2 zx2c4.com   -> sends my-email at example.com to the clipboard
>      pass zx2c4.com       -> sends hunter2 to stdout
>      ?????                -> how to send my-email at example.com to stdout?
> 
> I'd like to know if there's a way to send arbitrary lines to stdout,
> as can be done to the clipboard. Alternatively, commit 3a108277 seems
> to allow extraction of fields other than the password, but only for
> emacs.  Does something similar exist from the command line?  Meaning,
> if I modified my file as such:
> 
>      hunter2
>      email: my-email at example.com
> 
> could I do something like
> 
>      pass zx2c4.com :email -> send my-email at example.com to stdout

there are so many ways to do this in Unix.  the version which probably 
is least typing for the first usecase is

   pass zx2c4.com | sed -n 2p

-n turns off default print, 2p means on line 2, print.

your second feature is more awkward to type, so put it in an alias or 
function in your .bashrc:

   get() { sed -n "s/^$1: *//p"; }

usage will be:

   pass zx2c4.com | get email

-- 
Kjetil T. Homme
Redpill Linpro - Changing the Game


More information about the Password-Store mailing list