~ntgg/dotfiles

87e8c001afac66fda3d34c6b06adbcb21f5099f4 — Noah Graff a month ago 6b3f8ed
Revert "use posix shell not bash"

This reverts commit 53d766bf936077b02331359a93d47d84c6eef823.
1 files changed, 19 insertions(+), 12 deletions(-)

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

# not really sure what this does in bash FIXME
# shopt -s nullglob globstar
shopt -s nullglob globstar

typeit=0
if [[ $1 == "--type" ]]; then
	typeit=1
	shift
fi

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

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

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

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