Ask for confirmation on fuzzy entry matching

This commit is contained in:
Thorsten Wißmann 2015-12-05 12:26:14 +01:00
parent fb5e6e6c35
commit ffdc0f664f

View File

@ -19,7 +19,10 @@ Behaviour:
It will try to find a username/password entry in the configured backend
(currently only pass) for the current website and will load that pair of
username and password to any form on the current page that has some password
entry field.
entry field. If multiple entries are found, a zenity menu is offered.
If no entry is found, then it crops subdomains from the url if at least one
entry is found in the backend. (In that case, it always shows a menu)
EOF
}
@ -92,6 +95,8 @@ no_entries_found() {
simple_url=$(sed 's,^[^.]*\.,,' <<< "$simple_url")
query_entries "$simple_url"
#die "No entry found for »$simple_url«"
# enforce menu if we do "fuzzy" matching
menu_if_one_entry=1
done
if [ 0 -eq "${#files[@]}" ] ; then
die "No entry found for »$simple_url«"
@ -140,9 +145,11 @@ choose_entry_random() {
# dmenu or zenity or even qutebrowser completion in future?) which entry to
# pick
MENU_COMMAND=( head -n 1 )
# whether to show the menu if there is only one entrie in it
menu_if_one_entry=0
choose_entry_menu() {
local nr=${#files[@]}
if [ "$nr" -eq 1 ] ; then
if [ "$nr" -eq 1 ] && ! ((menu_if_one_entry)) ; then
file="${files[0]}"
else
file=$( printf "%s\n" "${files[@]}" | "${MENU_COMMAND[@]}" )