[pass] Add 'Change Dir' Functionality

Kenny Evitt kenny.evitt at gmail.com
Mon Sep 19 15:56:10 CEST 2016


I'm using a shell script with the following contents:

```
#!/usr/bin/env bash

# This script needs to be sourced to affect the user's environment.

repo_name=$1

if [[ -z "$repo_name" ]]; then
    echo "Error: No repo name was specified."
    return 1
fi

repo_path="$HOME/.password-store/$repo_name"

if [[ ! -d "$repo_path" ]]; then
    echo "Error: No Pass sub-directory with the name '$repo_name' exists."
    return 1
fi

export PASSWORD_STORE_GIT="$repo_path"
export PASSWORD_STORE_DIR="$repo_path"

echo "Switched to repo '$repo_name'!"
```

I named the script *pass-switch-repo.bash* and keep it in *~/bin*.

Note that you have to source the script for the changes it makes to the
environment variables to affect your current shell session, i.e. run `.
~/bin/pass-switch-repo.bash the-name-of-a-repo`.

You can still use Pass without having run (sourced) the script but the
`pass git ...` commands won't work (unless you've also setup your Pass root
directory as a Git repo).

On Mon, Sep 19, 2016 at 6:00 AM, <password-store-request at lists.zx2c4.com>
wrote:

> Send Password-Store mailing list submissions to
>         password-store at lists.zx2c4.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://lists.zx2c4.com/mailman/listinfo/password-store
> or, via email, send a message with subject or body 'help' to
>         password-store-request at lists.zx2c4.com
>
> You can reach the person managing the list at
>         password-store-owner at lists.zx2c4.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Password-Store digest..."
>
>
> Today's Topics:
>
>    1. Add 'Change Dir' Functionality (Jakob Holderbaum)
>    2. Re: Add 'Change Dir' Functionality (Lucas Hoffmann)
>    3. Re: Add 'Change Dir' Functionality (Brian Candler)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sun, 18 Sep 2016 13:52:19 +0200
> From: Jakob Holderbaum <pass at jakob.io>
> To: password-store at lists.zx2c4.com
> Subject: [pass] Add 'Change Dir' Functionality
> Message-ID: <20160918115219.GA10016 at steppenwolf.fritz.box>
> Content-Type: text/plain; charset="us-ascii"
>
> Hi pass Team,
>
> first and foremost, thanks for this great tool!
> We are currently using it at several client projects for storing shared
> team secrets like production credentials.
>
> This also means, that a rather often use-case is to call pass on different
> password directories. Setting PASSWORD_STORE_DIR individually for every
> call sometimes feels a bit awkward and let here and there even to mistakes.
>
> So I wan't to implement and submit a patch that basically implements the
> same 'Change Dir' functionality as it has been done for 'make' and 'git'.
>
> Both tools allow to specify the optional working dir with -C in front of
> the actual command. For example:
>
> `git -C ~/dev/dotfiles status`
>
> or
>
> `make -C ./build test`
>
> Wouldn't it be great if pass could provide the same interface:
>
> `pass -C ./secrets show production/database_password`
>
> instead of
>
> `PASSWORD_STORE_DIR=./secrets pass show production/database_password`
>
> If you think this would be a valuable extension, I would happily provide a
> patch for that.
>
> By the way, do you have any guidelines for submitting patches? I skimmed
> the pass website but could not find any.
>
> Thanks in advance!
>
> Cheers
> Jakob
> --
> Jakob Holderbaum
>
>   http://jakob.io/ | jakob at holderbaum.io
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: signature.asc
> Type: application/pgp-signature
> Size: 801 bytes
> Desc: not available
> URL: <http://lists.zx2c4.com/pipermail/password-store/
> attachments/20160918/bbd5d700/attachment-0001.asc>
>
> ------------------------------
>
> Message: 2
> Date: Sun, 18 Sep 2016 15:34:10 +0200
> From: Lucas Hoffmann <l-m-h at web.de>
> To: password-store at lists.zx2c4.com
> Subject: Re: [pass] Add 'Change Dir' Functionality
> Message-ID: <147420565065.6026.9624702959976314684 at mbp>
> Content-Type: text/plain; charset="utf-8"
>
> Quoting Jakob Holderbaum (2016-09-18 13:52:19)
> > We are currently using it at several client projects for storing
> > shared team secrets like production credentials.
> >
> > This also means, that a rather often use-case is to call pass on
> > different password directories. Setting PASSWORD_STORE_DIR
> > individually for every call sometimes feels a bit awkward and let here
> > and there even to mistakes.
> >
> > So I wan't to implement and submit a patch that basically implements
> > the same 'Change Dir' functionality as it has been done for 'make' and
> > 'git'.
>
> There where similar questions on the list before (can't give you the
> link right now, you have to search the archives yourself) but one
> proposed solution was to define aliases in your shell:
>
> alias pass-team1='PASSWORD_STORE_DIR=/somewhere/team1 pass'
> alias pass-team2='PASSWORD_STORE_DIR=/somewhere/team2 pass'
>
> Or you can use subfolders in PASSWORD_STORE_DIR with different gpg ids
> and use something like git subtree or submodule to manage that (just in
> case you did not know, see man page).
>
> Lucas
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: signature.asc
> Type: application/pgp-signature
> Size: 455 bytes
> Desc: signature
> URL: <http://lists.zx2c4.com/pipermail/password-store/
> attachments/20160918/43ec86be/attachment-0001.asc>
>
> ------------------------------
>
> Message: 3
> Date: Sun, 18 Sep 2016 16:54:21 +0100
> From: Brian Candler <b.candler at pobox.com>
> To: Jakob Holderbaum <pass at jakob.io>, password-store at lists.zx2c4.com
> Subject: Re: [pass] Add 'Change Dir' Functionality
> Message-ID: <e7f30443-2979-984d-eb1b-bb699d970456 at pobox.com>
> Content-Type: text/plain; charset=windows-1252; format=flowed
>
> On 18/09/2016 12:52, Jakob Holderbaum wrote:
> > Both tools allow to specify the optional working dir with -C in front of
> the actual command. For example:
> >
> > `git -C ~/dev/dotfiles status`
> >
> > or
> >
> > `make -C ./build test`
> >
> > Wouldn't it be great if pass could provide the same interface:
> >
> > `pass -C ./secrets show production/database_password`
>
> Another option I would like to see is to be able to use multiple git
> repos within the tree. This could then be combined with symlinks: e.g.
>
> .password_store/secrets -> /home/me/secrets
> .password_store/customer1 -> /home/me/customers/one/password_store
>
> Then you could do:
>
> pass show secrets/production/database_password
>
> as if it were were a single pass tree (but actually commits would take
> place within secrets/.git)
>
> Regards,
>
> Brian.
>
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Password-Store mailing list
> Password-Store at lists.zx2c4.com
> http://lists.zx2c4.com/mailman/listinfo/password-store
>
>
> ------------------------------
>
> End of Password-Store Digest, Vol 40, Issue 10
> **********************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20160919/d9004e7a/attachment.html>


More information about the Password-Store mailing list