aboutsummaryrefslogtreecommitdiff
path: root/bin/dmp
blob: 95829296cad2d75dc94cbdcc6c064a2de7c95a98 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh

# Get the password store directory, bail if we can't
pwsd=${PASSWORD_STORE_DIR:-$HOME/.password-store}
pwsd=${pwsd%/}
[ -n "$pwsd" ] || exit

# Get the password; get all the names from find(1)
pw=$(
    cd -- "$pwsd" || exit
    # Get all the names from find(1)
    find ./ -name \*.gpg |
    # Sort them
    sort |
    # Strip the leading directory and the trailing .gpg
    sed '
s_^\./__
s_\.gpg$__
    ' |
    # Use dmenu(1) to prompt the user to select one
    dmenu
)

# Bail if we don't have a password
[ -n "$pw" ] || exit

# Pump the password into the clipboard xsel(2); allow 10 seconds
pass show "$pw" | xsel -ibt 10000