Bash script for copying and autotyping data from password-store, gopass or prs.

add prs support

+17 -8
+1 -1
config
··· 4 4 # configuration file for tessen 5 5 # place this file in $XDG_CONFIG_HOME/tessen/config 6 6 7 - # the default pass program to use - pass or gopass 7 + # the default pass program to use - pass, gopass or prs 8 8 # pass_backend="pass" 9 9 10 10 # the default dmenu backend program to use - rofi, fuzzel, bemenu, rofi, or dmenu
+16 -7
tessen
··· 6 6 # ------------------------------------------------------------------------------ 7 7 8 8 # don't leak password data if debug mode is enabled 9 - #set +x 9 + set -x 10 10 11 11 # GLOBAL VARIABLES 12 12 declare _PASS_BACKEND _DMENU_BACKEND _TSN_ACTION _TSN_CONFIG ··· 97 97 98 98 if [[ $_PASS_BACKEND == "pass" ]]; then 99 99 mapfile -t passdata < <(pass show "$_TSN_PASSFILE" 2> /dev/null) 100 + if [[ ${#passdata[@]} -eq 0 ]]; then 101 + _die "the selected file is empty" 102 + fi 103 + elif [[ $_PASS_BACKEND == "prs" ]]; then 104 + mapfile -t passdata < <(prs show "$_TSN_PASSFILE" 2> /dev/null) 100 105 if [[ ${#passdata[@]} -eq 0 ]]; then 101 106 _die "the selected file is empty" 102 107 fi ··· 314 319 315 320 if [[ $_PASS_BACKEND == "pass" ]]; then 316 321 tmp_otp="$(pass otp "$_TSN_PASSFILE")" 322 + elif [[ $_PASS_BACKEND == "prs" ]]; then 323 + tmp_otp="$(prs otp show --quiet "$_TSN_PASSFILE")" 317 324 elif [[ $_PASS_BACKEND == "gopass" ]]; then 318 325 tmp_otp="$(gopass otp -o "$_TSN_PASSFILE")" 319 326 fi ··· 394 401 printf "%s\n" "invalid clipboard timeout value in PASSWORD_STORE_CLIP_TIME" >&2 395 402 return 1 396 403 fi 404 + elif [[ $_PASS_BACKEND == "prs" ]]; then 405 + tsn_cliptime="20" 397 406 elif [[ $_PASS_BACKEND == "gopass" ]]; then 398 407 tsn_cliptime="$(gopass config core.cliptimeout)" 399 408 tsn_cliptime="${tsn_cliptime##*: }" ··· 430 439 431 440 validate_pass_backend() { 432 441 if ! is_installed "$1"; then 433 - _die "please install a valid password store backend: pass | gopass" 442 + _die "please install a valid password store backend: pass | gopass | prs" 434 443 fi 435 - if [[ $1 == "pass" ]] || [[ $1 == "gopass" ]]; then 444 + if [[ $1 == "pass" ]] || [[ $1 == "gopass" ]] || [[ $1 == "prs" ]]; then 436 445 _PASS_BACKEND="$1" 437 446 else 438 - _die "please specify a valid password store backend: pass | gopass" 447 + _die "please specify a valid password store backend: pass | gopass | prs" 439 448 fi 440 449 } 441 450 ··· 526 535 } 527 536 528 537 find_pass_backend() { 529 - local -a tmp_pass_arr=('pass' 'gopass') 538 + local -a tmp_pass_arr=('pass' 'gopass' 'prs') 530 539 local idx 531 540 532 541 for idx in "${tmp_pass_arr[@]}"; do ··· 536 545 fi 537 546 done 538 547 if [[ -z $_PASS_BACKEND ]]; then 539 - _die "please install a valid password store backend: pass | gopass" 548 + _die "please install a valid password store backend: pass | gopass | prs" 540 549 fi 541 550 542 551 unset -v idx tmp_pass_arr ··· 811 820 fi 812 821 813 822 trap '_clear' EXIT TERM INT 814 - if [[ $_PASS_BACKEND == "pass" ]]; then 823 + if [[ $_PASS_BACKEND == "pass" ]] || [[ $_PASS_BACKEND == "prs" ]]; then 815 824 get_pass_files 816 825 elif [[ $_PASS_BACKEND == "gopass" ]]; then 817 826 get_gopass_files