q.sh/q-pass

36 lines
977 B
Text
Raw Normal View History

#!/bin/sh
2021-11-21 21:52:45 +00:00
2023-05-14 19:24:27 +00:00
ENV_pass=pass
ENV_find=find
ENV_sed=sed
ENV_wl_copy=wl-copy
2021-11-21 21:52:45 +00:00
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 .*$"
2021-11-21 21:52:45 +00:00
elif [[ "$1" == "--hint" ]]; then
# This subcommand has no hints
shift
2021-11-21 21:52:45 +00:00
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
$ENV_find . -name "*.gpg" | $ENV_sed -E 's/\.\/(.*)\.gpg/\1 p \1/'
2021-11-21 21:52:45 +00:00
elif [[ "$1" == "--preview" ]]; then
shift
# This information will be displayed in the preview
# pane on the right.
echo "Will get password for $1"
2021-11-21 21:52:45 +00:00
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"
2024-11-03 02:17:28 +00:00
$ENV_pass "$NAME" | (setsid -f $ENV_wl_copy)
2021-11-21 21:52:45 +00:00
fi