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

add prs support #2

merged opened by jcg.re targeting main from push-vwswylplsrxo
Labels

None yet.

assignee

None yet.

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

Submissions

sign up or login to add to the discussion
jcg.re submitted #8
1 commit
expand
feat: add prs support
pull request successfully merged
jcg.re submitted #7
1 commit
expand
feat: add prs support
jcg.re submitted #6
1 commit
expand
feat: add prs support
jcg.re submitted #5
1 commit
expand
feat: add prs support
jcg.re submitted #4
1 commit
expand
feat: add prs support
jcg.re submitted #3
1 commit
expand
feat: add prs support
jcg.re submitted #2
1 commit
expand
feat: add prs support
jcg.re submitted #1
1 commit
expand
feat: add prs support
jcg.re submitted #0
1 commit
expand
add prs support