[pass] Multiple password contexts

Kenny Evitt kenny.evitt at gmail.com
Wed Nov 16 15:31:20 CET 2016


Here's my hack solution:

I have a script, somewhere in my path, and I've named it
*pass-switch-repo.bash*. Here's its 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'!"
```

Because it's modifying environment variables, you have to source it, e.g.:

`. pass-switch-repo.bash name-of-a-pass-context`

Bash and Git completion work just as with a regular Pass password store
("repo" per my script).

The script assumes you've organized your 'contexts' as sub-directories of
the default password store directory.

On Tue, Nov 15, 2016 at 8:52 PM, Andrew Dunn <andrew.g.dunn at gmail.com>
wrote:

> Adam:
>
> Interesting suggestion! However, it appears that it might break the
> git completion when you do that... or maybe I set something up wrong?
>
> On Mon, Nov 14, 2016 at 7:44 PM, Adam Liter <io at adamliter.org> wrote:
> > You can also set up autocompletion for these aliases, e.g.:
> >
> > -----------------------------------------------------
> >
> > # ~/.bashrc
> >
> > alias p1="PASSWORD_STORE_DIR=~/p1 pass"
> > alias p2="PASSWORD_STORE_DIR=~/p2 pass"
> >
> > source /usr/local/etc/bash_completion.d/password-store
> >
> > _p1(){
> >     PASSWORD_STORE_DIR=~/p1 _pass
> > }
> >
> > complete -o filenames -o nospace -F _p1 p1
> >
> > _p2(){
> >     PASSWORD_STORE_DIR=~/p2 _pass
> > }
> >
> > complete -o filenames -o nospace -F _p2 p2
> >
> > -----------------------------------------------------
> >
> > Hope this helps!
> >
> > -Adam
> >
> > On 14 Nov 2016, at 10:14, Lenz Weber wrote:
> >
> >> something along the lines of
> >>
> >> alias p1="PASSWORD_STORE_DIR=~/p1 pass"
> >> alias p2="PASSWORD_STORE_DIR=~/p2 pass"
> >>
> >> would allow you to call p1 and p2 for the two folders respectively.
> >>
> >> On 11/14/2016 04:08 PM, Andrew Dunn wrote:
> >>> But that's the fastest way, to modify an envar? I see qtpass seems to
> >>> have a tab for multiple stores, I was just hoping to stick with cli.
> >>>
> >>> On Mon, Nov 14, 2016 at 10:07 AM, Lenz Weber <mail at lenzw.de> wrote:
> >>>> just set the PASSWORD_STORE_DIR environment variable before calling
> pass.
> >>>>
> >>>>
> >>>> On 11/14/2016 04:00 PM, Andrew Dunn wrote:
> >>>>> I might have completely missed this in documentation, but is it
> >>>>> possible to have multiple password roots? I'm currently managing this
> >>>>> with some bash aliases that remove/re-symlink to different
> >>>>> repositories. My use case is that I have multiple contexts for
> sharing
> >>>>> passwords with others.
> >>>>> _______________________________________________
> >>>>> Password-Store mailing list
> >>>>> Password-Store at lists.zx2c4.com
> >>>>> http://lists.zx2c4.com/mailman/listinfo/password-store
> >>
> >> _______________________________________________
> >> Password-Store mailing list
> >> Password-Store at lists.zx2c4.com
> >> http://lists.zx2c4.com/mailman/listinfo/password-store
> _______________________________________________
> Password-Store mailing list
> Password-Store at lists.zx2c4.com
> http://lists.zx2c4.com/mailman/listinfo/password-store
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20161116/dec01c7e/attachment.html>


More information about the Password-Store mailing list