This adds the following additional argument to passmenu:
passmenu --line=2It does make use of sed to be able to type the specified line, which might or might not be an issue. --- contrib/dmenu/README.md | 13 +++++++------ contrib/dmenu/passmenu | 25 ++++++++++++++++++------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/contrib/dmenu/README.md b/contrib/dmenu/README.md index 9d54fb4..ab6afaa 100644 --- a/contrib/dmenu/README.md +++ b/contrib/dmenu/README.md @@ -1,12 +1,13 @@ -`passmenu` is a [dmenu][]-based interface to [pass][], the standard Unix -password manager. This design allows you to quickly copy a password to the -clipboard without having to open up a terminal window if you don't already have -one open. If `--type` is specified, the password is typed using [xdotool][] -instead of copied to the clipboard. +`passmenu` is a [dmenu][]-based interface to [pass][], the standard +Unix password manager. This design allows you to quickly copy a +password to the clipboard without having to open up a terminal window +if you don't already have one open. If `--type` is specified, the +password is typed using [xdotool][] instead of copied to the +clipboard. Use `--line=N` to specify which line to copy/type. # Usage - passmenu [--type] [dmenu arguments...] + passmenu [--type] [--line=N] [dmenu arguments...] [dmenu]: http://tools.suckless.org/dmenu/ [xdotool]: http://www.semicomplete.com/projects/xdotool/ diff --git a/contrib/dmenu/passmenu b/contrib/dmenu/passmenu index 7a9c517..fdae88f 100755 --- a/contrib/dmenu/passmenu +++ b/contrib/dmenu/passmenu @@ -3,10 +3,20 @@ shopt -s nullglob globstar typeit=0 -if [[ $1 == "--type" ]]; then - typeit=1 - shift -fi +line=1 + +for arg in "$@"; do + case $arg in + --type) + typeit=1 + shift + ;; + --line=*) + line="${arg#*=}" + shift + ;; + esac +done prefix=${PASSWORD_STORE_DIR-~/.password-store} password_files=( "$prefix"/**/*.gpg ) @@ -18,8 +28,9 @@ password=$(printf '%s\n' "${password_files[@]}" | dmenu "$@") [[ -n $password ]] || exit if [[ $typeit -eq 0 ]]; then - pass show -c "$password" 2>/dev/null + pass show -c"$line" "$password" 2>/dev/null else - pass show "$password" | { read -r pass; printf %s "$pass"; } | - xdotool type --clearmodifiers --file - + pass show "$password" | sed -n "$line"p | + { read -r pass; printf %s "$pass"; } | + xdotool type --clearmodifiers --file - fi -- 2.7.0
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Password-Store mailing list [email protected] http://lists.zx2c4.com/mailman/listinfo/password-store
