pash: clear clipboard after a timer

This commit is contained in:
Dylan Araps 2019-11-30 10:19:32 +00:00
parent 7b3be8069c
commit 328ca19ad6
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
2 changed files with 36 additions and 11 deletions

View File

@ -26,6 +26,7 @@ pash
* [How do I set the password length?](#how-do-i-set-the-password-length)
* [How do I change the password store location?](#how-do-i-change-the-password-store-location)
* [How do I change the clipboard tool?](#how-do-i-change-the-clipboard-tool)
* [How do I change the clipboard timeout?](#how-do-i-change-the-clipboard-timeout)
* [How do I change the password generation pattern?](#how-do-i-change-the-password-generation-pattern)
* [How do I rename an entry?](#how-do-i-rename-an-entry)
* [How can I migrate from `pass` to `pash`?](#how-can-i-migrate-from-pass-to-pash)
@ -61,11 +62,12 @@ COMMANDS
OPTIONS
Using a key pair: export PASH_KEYID=XXXXXXXX
Password length: export PASH_LENGTH=50
Password pattern: export PASH_PATTERN=_A-Z-a-z-0-9
Store location: export PASH_DIR=~/.local/share/pash
Clipboard tool: export PASH_CLIP='xclip -selection clipboard'
Using a key pair: export PASH_KEYID=XXXXXXXX
Password length: export PASH_LENGTH=50
Password pattern: export PASH_PATTERN=_A-Z-a-z-0-9
Store location: export PASH_DIR=~/.local/share/pash
Clipboard tool: export PASH_CLIP='xclip -selection clipboard'
Clipboard timeout: export PASH_TIMEOUT=10
```
## FAQ
@ -136,6 +138,18 @@ export PASH_CLIP='xclip -selection clipboard'
PASH_CLIP='xclip -selection clipboard' pash copy github
```
### How do I change the clipboard timeout?
Set the environment variable `PASH_TIMEOUT` to a command.
```sh
# Default: '10'
export PASH_TIMEOUT=10
# This can also be used as a one-off.
PASH_TIMEOUT=5 pash copy github
```
### How do I change the password generation pattern?
Set the environment variable `PASH_PATTERN` to a valid `tr` string.

23
pash
View File

@ -58,7 +58,17 @@ pw_copy() {
# Disable warning against word-splitting as it is safe
# and intentional (globbing is disabled).
# shellcheck disable=2086
pw_show "$1" | ${PASH_CLIP:-xclip -selection clipboard}
: "${PASH_CLIP:=xclip -selection clipboard}"
# Wait in the background for the password timeout and
# clear the clipboard when the timer runs out.
(
printf 'Clearing clipboard in %d seconds.\n' "${PASH_TIMEOUT:=10}"
sleep "$PASH_TIMEOUT"
printf '' | $PASH_CLIP
) &
pw_show "$1" | $PASH_CLIP
}
pw_list() {
@ -119,11 +129,12 @@ pash 2.1.0 - simple password manager.
=> [l]ist - List all entries.
=> [s]how [name] - Show password for an entry.
Using a key pair: export PASH_KEYID=XXXXXXXX
Password length: export PASH_LENGTH=50
Password pattern: export PASH_PATTERN=_A-Z-a-z-0-9
Store location: export PASH_DIR=~/.local/share/pash
Clipboard tool: export PASH_CLIP='xclip -selection clipboard'
Using a key pair: export PASH_KEYID=XXXXXXXX
Password length: export PASH_LENGTH=50
Password pattern: export PASH_PATTERN=_A-Z-a-z-0-9
Store location: export PASH_DIR=~/.local/share/pash
Clipboard tool: export PASH_CLIP='xclip -selection clipboard'
Clipboard timeout: export PASH_TIMEOUT=10
"
exit 1
}