Skip to content

Commit

Permalink
Rename clip function
Browse files Browse the repository at this point in the history
  • Loading branch information
drduh committed Jul 4, 2024
1 parent 849920c commit 70e4898
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions purse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}

Expand All @@ -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
Expand All @@ -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}"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 70e4898

Please sign in to comment.