From afc8e1994a720ca0a68fcae96cb24c5be3a9964e Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 2 Mar 2019 21:57:59 +0100 Subject: [PATCH] Add support for "showfields" in entries Fixes https://github.com/carnager/rofi-pass/issues/158. --- rofi-pass | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/rofi-pass b/rofi-pass index 48928db..5cad06b 100755 --- a/rofi-pass +++ b/rofi-pass @@ -19,6 +19,10 @@ USERNAME_field='user' AUTOTYPE_field='autotype' OTPmethod_field='otp_method' +# Display these fields with entries. +# NOTE: no default here, handled in code. +SHOWFIELDS_field='showfields' + default_autotype="user :tab pass" delay=2 wait=0.2 @@ -495,9 +499,17 @@ typeMenu () { if [[ -n $default_do ]]; then if [[ $default_do == "menu" ]]; then checkIfPass - local -a keys=("${!stuff[@]}") - keys=("${keys[@]/$AUTOTYPE_field}") - typefield=$({ printf '%s' "${AUTOTYPE_field}" ; printf '%s\n' "${keys[@]}" | sort; } | _rofi -dmenu -p "Choose Field to type > ") + + local show_fields + if [[ -z "${stuff[$SHOWFIELDS_field]}" ]]; then + local -a keys=("${!stuff[@]}") + keys=("${keys[@]/$AUTOTYPE_field}") + declare -p keys stuff + show_fields=$(printf '%s' "${AUTOTYPE_field}" ; printf '%s\n' "${keys[@]}" | sort) + else + show_fields=$(printf '%s\n' "${stuff["$SHOWFIELDS_field"]}") + fi + typefield=$(echo "$show_fields" | _rofi -dmenu -p "Choose Field to type > ") typefield_exit=$? if [[ $typefield_exit -eq 1 ]]; then exit