From 70e48984e8782d103b5311bb0b7b233d1b83f94a Mon Sep 17 00:00:00 2001 From: drduh Date: Thu, 4 Jul 2024 15:59:36 -0700 Subject: [PATCH] Rename clip function --- README.md | 2 +- purse.sh | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0d78046..44f05ec 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ tar xvf purse*tar Several customizable options and features are also available, and can be configured with environment variables, for example in the [shell rc](https://github.com/drduh/config/blob/master/zshrc) file: -Variable | Description | Default | Values +Variable | Description | Default | Available options -|-|-|- `PURSE_CLIP` | clipboard to use | `xclip` | `pbcopy` on macOS `PURSE_CLIP_ARGS` | arguments to pass to clipboard command | unset (disabled) | `-i -selection clipboard` to use primary (control-v) clipboard with xclip diff --git a/purse.sh b/purse.sh index 0a236a7..e7b1a28 100755 --- a/purse.sh +++ b/purse.sh @@ -133,7 +133,7 @@ read_pass () { fail "Secret not available" ; fi prompt_key "password" - clip <(decrypt "${spath}" | head -1) || \ + emit_pass <(decrypt "${spath}" | head -1) || \ fail "Failed to decrypt ${spath}" } @@ -152,7 +152,8 @@ generate_pass () { else length="${3}" ; fi if [[ "${length}" =~ ^[0-9]+$ ]] ; then - pass_len="${length}" ; fi + pass_len="${length}" + fi tr -dc "${pass_chars}" < /dev/urandom | \ fold -w "${pass_len}" | head -1 @@ -175,7 +176,7 @@ write_pass () { fold -w10 | head -1)" if [[ -n "${pass_copy}" ]] ; then - clip <(printf '%s' "${userpass}") ; fi + emit_pass <(printf '%s' "${userpass}") ; fi printf '%s\n' "${userpass}" | encrypt "${spath}" - || \ fail "Failed saving ${spath}" @@ -220,7 +221,7 @@ backup () { else warn "${safe_backup} exists, skipping archive" ; fi } -clip () { +emit_pass () { # Use clipboard or stdout and clear after timeout. if [[ "${clip_dest}" = "screen" ]] ; then