[PATCH v3] clip: add option PASSWORD_STORE_PASTE_ONCE
-g
grmat at sub.red
Mon Nov 23 17:08:00 CET 2020
If this environment variable is set to "true", the clipboard is cleared
immediately after pasting.
v2: add xclip support
v3: fix xclip long option
---
man/pass.1 | 4 ++++
src/password-store.sh | 8 ++++++++
2 files changed, 12 insertions(+)
diff --git a/man/pass.1 b/man/pass.1
index a555dcb..5930cdd 100644
--- a/man/pass.1
+++ b/man/pass.1
@@ -429,6 +429,10 @@ for more info.
Specifies the number of seconds to wait before restoring the clipboard, by default
\fI45\fP seconds.
.TP
+.I PASSWORD_STORE_PASTE_ONCE
+If this variable is set to \fItrue\fP, the clipboard is cleared immediately after the copied
+password has been pasted.
+.TP
.I PASSWORD_STORE_UMASK
Sets the umask of all files modified by pass, by default \fI077\fP.
.TP
diff --git a/src/password-store.sh b/src/password-store.sh
index 77f3eda..b30b7cd 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -16,6 +16,7 @@ PREFIX="${PASSWORD_STORE_DIR:-$HOME/.password-store}"
EXTENSIONS="${PASSWORD_STORE_EXTENSIONS_DIR:-$PREFIX/.extensions}"
X_SELECTION="${PASSWORD_STORE_X_SELECTION:-clipboard}"
CLIP_TIME="${PASSWORD_STORE_CLIP_TIME:-45}"
+PASTE_ONCE="${PASSWORD_STORE_PASTE_ONCE:-false}"
GENERATED_LENGTH="${PASSWORD_STORE_GENERATED_LENGTH:-25}"
CHARACTER_SET="${PASSWORD_STORE_CHARACTER_SET:-[:punct:][:alnum:]}"
CHARACTER_SET_NO_SYMBOLS="${PASSWORD_STORE_CHARACTER_SET_NO_SYMBOLS:-[:alnum:]}"
@@ -154,17 +155,24 @@ check_sneaky_paths() {
clip() {
if [[ -n $WAYLAND_DISPLAY ]]; then
+
local copy_cmd=( wl-copy )
local paste_cmd=( wl-paste -n )
if [[ $X_SELECTION == primary ]]; then
copy_cmd+=( --primary )
paste_cmd+=( --primary )
fi
+ if [[ $PASTE_ONCE == true ]]; then
+ copy_cmd+=( --paste-once )
+ fi
local display_name="$WAYLAND_DISPLAY"
elif [[ -n $DISPLAY ]]; then
local copy_cmd=( xclip -selection "$X_SELECTION" )
local paste_cmd=( xclip -o -selection "$X_SELECTION" )
local display_name="$DISPLAY"
+ if [[ $PASTE_ONCE == true ]]; then
+ copy_cmd+=( -loops 1 )
+ fi
else
die "Error: No X11 or Wayland display detected"
fi
--
2.29.2
More information about the Password-Store
mailing list