Skip to content

Instantly share code, notes, and snippets.

@Alveel
Last active August 1, 2019 08:20
Show Gist options
  • Save Alveel/d26c3b524d785af6fb0037394dd1f25e to your computer and use it in GitHub Desktop.
Save Alveel/d26c3b524d785af6fb0037394dd1f25e to your computer and use it in GitHub Desktop.
passmenu for pass-otp
#!/usr/bin/env bash
shopt -s nullglob globstar
otp_dir=totp
prefix=${PASSWORD_STORE_DIR-~/.password-store}
password_files=( "$prefix"/"$otp_dir"/*.gpg )
password_files=( "${password_files[@]#"$prefix"/}" )
password_files=( "${password_files[@]%.gpg}" )
password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@")
[[ -n $password ]] || exit
pass otp show -c "$password" 2>/dev/null
diff --git a/usr/bin/passmenu b/.local/bin/otpmenu
index 83268bc..c3ebdf6 100755
--- a/usr/bin/passmenu
+++ b/.local/bin/otpmenu
@@ -2,14 +2,10 @@
shopt -s nullglob globstar
-typeit=0
-if [[ $1 == "--type" ]]; then
- typeit=1
- shift
-fi
+otp_dir=totp
prefix=${PASSWORD_STORE_DIR-~/.password-store}
-password_files=( "$prefix"/**/*.gpg )
+password_files=( "$prefix"/"$otp_dir"/*.gpg )
password_files=( "${password_files[@]#"$prefix"/}" )
password_files=( "${password_files[@]%.gpg}" )
@@ -17,9 +13,5 @@ password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@")
[[ -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
+pass otp show -c "$password" 2>/dev/null
+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment