Add pass integration

This commit is contained in:
Konstantin Nazarov 2021-11-21 21:52:45 +00:00
parent be2989f582
commit b93ba0632d
Signed by: knazarov
GPG key ID: 4CFE0A42FA409C22

34
q-pass Executable file
View file

@ -0,0 +1,34 @@
#!/bin/bash
if [[ -z "$@" ]]; then
# Return a regular expression that should trigger
# this subcommand. q.sh will then pass control to
# this script whenever the input line matches.
echo "^p .*$"
elif [[ "$1" == "--hint" ]]; then
# This subcommand has no hints
shift
elif [[ "$1" == "--complete" ]]; then
shift
# Return a list of all accounts for which we store
# passwords. This will be used to provide a list of
# completions.
cd ~/.password-store
find . -name "*.gpg" | sed -E 's/\.\/(.*)\.gpg/\1 p \1/'
elif [[ "$1" == "--preview" ]]; then
shift
# This information will be displayed in the preview
# pane on the right.
echo "Will get password for $1"
elif [[ "$1" == "--run" ]]; then
shift
# This will be triggered when enter is pressed on
# one of the options. We now decrypt the password
# and place it to the clipboard.
NAME="$1"
pass "$NAME" | (nohup wl-copy -n 2>/dev/null &)
# A short sleep is needed to wait for child process
# to spawn before exiting.
sleep 0.01
fi