[pass] [PATCH 1/2] Split xclip stuff into its own function

Marc-Antoine Perennou Marc-Antoine at Perennou.com
Mon May 11 16:08:38 CEST 2015


Signed-off-by: Marc-Antoine Perennou <Marc-Antoine at Perennou.com>
---
 src/password-store.sh | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/password-store.sh b/src/password-store.sh
index d535a74..06fb33f 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -127,12 +127,12 @@ check_sneaky_paths() {
 # BEGIN platform definable
 #
 
-clip() {
+clip_xclip() {
 	# This base64 business is because bash cannot store binary data in a shell
 	# variable. Specifically, it cannot store nulls nor (non-trivally) store
 	# trailing new lines.
-	local sleep_argv0="password store sleep on display $DISPLAY"
-	pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
+	local sleep_argv0="$1"
+	shift
 	local before="$(xclip -o -selection "$X_SELECTION" 2>/dev/null | base64)"
 	echo -n "$1" | xclip -selection "$X_SELECTION" || die "Error: Could not copy data to the clipboard"
 	(
@@ -151,6 +151,11 @@ clip() {
 
 		echo "$before" | base64 -d | xclip -selection "$X_SELECTION"
 	) 2>/dev/null & disown
+}
+clip() {
+	local sleep_argv0="password store sleep on display $DISPLAY"
+	pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
+	clip_xclip "$sleep_argv0" "$@"
 	echo "Copied $2 to clipboard. Will clear in $CLIP_TIME seconds."
 }
 tmpdir() {
-- 
2.3.3



More information about the Password-Store mailing list