~ntgg/dotfiles

53d766bf936077b02331359a93d47d84c6eef823 — Noah Graff 2 months ago a27dea9
use posix shell not bash
1 files changed, 12 insertions(+), 19 deletions(-)

M .local/bin/passmenu
M .local/bin/passmenu => .local/bin/passmenu +12 -19
@@ 1,25 1,18 @@
#!/usr/bin/env bash
#!/usr/bin/env sh

shopt -s nullglob globstar

typeit=0
if [[ $1 == "--type" ]]; then
	typeit=1
	shift
fi
# not really sure what this does in bash FIXME
# shopt -s nullglob globstar

prefix=${PASSWORD_STORE_DIR-~/.password-store}
password_files=( "$prefix"/**/*.gpg )
password_files=( "${password_files[@]#"$prefix"/}" )
password_files=( "${password_files[@]%.gpg}" )
password=$(
    echo "$prefix"/**/*.gpg |
    tr ' ' '\n' |
    sed "s#$prefix"'/##g' |
    sed 's/[.]gpg//g' |
    wofi -Sdmenu
)

password=$(printf '%s\n' "${password_files[@]}" | wofi -Sdmenu "$@")
[ -n "$password" ] || exit

[[ -n $password ]] || exit
pass show -c "$password" 2>/dev/null

if [[ $typeit -eq 0 ]]; then
	pass show -c "$password" 2>/dev/null
else
	pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } |
		xdotool type --clearmodifiers --file -
fi