From 942797d0e6ada52a226e2e320e7735b6d502c0c2 Mon Sep 17 00:00:00 2001 From: Eric Phillips Date: Thu, 30 Mar 2017 22:32:15 -0600 Subject: [PATCH] dpass to use pass from dmenu --- dpass.bash | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 dpass.bash diff --git a/dpass.bash b/dpass.bash new file mode 100755 index 0000000..e46a02f --- /dev/null +++ b/dpass.bash @@ -0,0 +1,28 @@ +#!/bin/bash +#based on https://github.com/cdown/passmenu +#and jasnowryan.com/blog + +shopt -s nullglob globstar + +nb='#2F4F4F' +nf='#00FFFF' +sb='#2F4F4F' +sf='#ADFF2F' +font="Inconsolataicon-12" +dmenucmd=( dmenu -i -fn "$font" -nb "$nb" -nf "$nf" -sb "$sb" -sf "$sf" ) + +prefix=${PASSWORD_STORE_DIR:-~/.password-store} +files=( "$prefix"/**/*.gpg ) +files=( "${files[@]#"$prefix"/}" ) +files=( "${files[@]%.gpg}" ) +fbase=( "${files[@]##*/}" ) + +word=$(printf '%s\n' "${fbase[@]}" | "${dmenucmd[@]}" "$@") + +if [[ -n $word ]]; then + for match in "${files[@]}"; do + if [[ $word == ${match#*/} ]]; then + /usr/bin/pass show -c "$match" 2>/dev/null + fi + done +fi