Giter Club home page Giter Club logo

pass-cl's Introduction

About

An extension for password-store that copies the password and additional metadata (e.g. login name) into separate X selections.

Defaults:

  • password: PASSWORD_STORE_X_SELECTION=clipboard (default in pass)
  • metadata: PASSWORD_STORE_X_SELECTION_META=primary (this extension)

See below for more on X selections.

The default from pass insert foo results in a one-line password file ($PASSWORD_STORE_DIR/foo.gpg).

passzzwoo00rrd11!!1!!

A common use case is to copy this using pass show -c foo (or just pass -c foo, show is default) into the Clipboard X selection (CTRL-V to paste).

pass also supports multiple lines (pass insert -m foo) in which the password is on the first line (or any other with pass -c <line_number> foo) and arbitrary metadata on the other lines. A typical entry would look like this:

passzzwoo00rrd11!!1!!
[email protected]
meta:bar
more meta=baz
otherstuff

where the second line could be the login name. However, everything except the password line is ignored by pass -c. It can only be displayed with another pass foo and copied manually if needed. This extension additionally copies the second line (by default) to another X selection (PASSWORD_STORE_X_SELECTION_META).

Usage

$ pass cl foo

The default behavior is to copy the first line (password) to the Clipboard as usual (like pass -c foo, paste with CTRL-V). Additionally, the second line is copied into the Primary selection (Shift-Insert or middle mouse button to paste). We can use the xclip tool to check what we copied into which selection.

$ xclip -o -sel clip
passzzwoo00rrd11!!1!!
$ xclip -o -sel prim
[email protected]

The typical workflow is thus pass cl foo, go to where credentials need to be inserted (e.g. the browser), middle mouse -> login, CTRL-V -> password.

Select a metadata line

If you want to copy metadata from another line than the second, you can use -l <line_number>.

$ pass cl -l5 foo
$ xclip -o -sel prim
otherstuff

Alternatively, you can use the -r option to provide a regex matching that line.

$ pass cl -r meta: foo
$ xclip -o -sel prim
bar

The matching part of the line is removed, leaving only the metadata. This is useful for selecting lines by prefix (such as meta:). Hint: avoid whitespaces in your metadata lines (meta:bar instead of meta : bar) to keep the regex simple. In the last example we would need -r 'meta\s+:\s+' to match all whitespaces since we want the complete match to be removed, leaving only bar without any whitespace.

Swap selection content

pass show copies the password to Clipboard. If you need to paste this in a shell where you cannot use CTRL-V (e.g. XTerm), you can copy it to Primary instead with plain pass like so:

$ PASSWORD_STORE_X_SELECTION=primary pass -c foo

and paste that in the shell or anywhere else with Shift-Insert or the middle mouse button. With pass cl, you can use the -s flag to swap the content of Primary and Clipboard to have the password in Primary.

$ pass cl -s foo

Check:

$ xclip -o -sel clip
[email protected]
$ xclip -o -sel prim
passzzwoo00rrd11!!1!!
$ <Shift-Insert>
passzzwoo00rrd11!!1!!

pass compatibility

Make sure to place this extension's options right after cl

$ pass cl [options] foo

else pass's command line parser will complain.

We do not support any options of pass show such as -c|--clip [<line_number>] or -q|--qrcode [<line_number>]. For instance these won't work

$ pass cl -c [<line_number>] foo    # error
$ pass cl foo -c [<line_number>]    # ignored

If you want to use those, please use pass show directly and deal with metadata in another way. Here, the password is always copied from the first line.

Installation

$ export PASSWORD_STORE_ENABLE_EXTENSIONS=true
$ export PASSWORD_STORE_EXTENSIONS_DIR=$HOME/.pass_extensions
$ mkdir -p $PASSWORD_STORE_EXTENSIONS_DIR
$ ln -s $(pwd)/cl.bash $PASSWORD_STORE_EXTENSIONS_DIR/cl.bash

X selections

There are different X selections (see xclip -selection):

  • primary: default in xclip, use Shift-Insert or the middle mouse button to paste
  • secondary: usually not used
  • clipboard: CTRL-V to paste in most GUI apps

See also xclip-dump.

pass-cl's People

Contributors

elcorto avatar lorenzbischof avatar

Stargazers

 avatar

Watchers

 avatar  avatar

pass-cl's Issues

Quotes missing from $passfile variable on line 90

I use subdirectories in my password-store and they sometimes include spaces.

I had to add quotes to the $passfile variable on line 90 of cl.bash so the line now reads:

[ -f "$passfile" ] || err "$path is not in the password store"

Otherwise it produced the error:

.pass_extensions/cl.bash: line 91: [: too many arguments

Thanks for the extension! It's exactly what I was looking for.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.