No subject

Wu Zhenyu wuzhenyu at ustc.edu
Sat Nov 5 16:28:22 UTC 2022


From: Wu Zhenyu <wuzhenyu at ustc.edu>
To: password-store at lists.zx2c4.com
Cc: Wu Zhenyu <wuzhenyu at ustc.edu>
Subject: [PATCH] support more clippers
Date: Sun,  6 Nov 2022 00:28:02 +0800
Message-Id: <20221105162801.1471986-1-wuzhenyu at ustc.edu>
X-Mailer: git-send-email 2.38.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Change xclip to an optional depend
Refer <https://github.com/neovim/neovim/issues/20862>
---
 src/password-store.sh | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/src/password-store.sh b/src/password-store.sh
index 22e818f..0af39d5 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -163,12 +163,35 @@ clip() {
 			paste_cmd+=( --primary )
 		fi
 		local display_name="$WAYLAND_DISPLAY"
-	elif [[ -n $DISPLAY ]] && command -v xclip &> /dev/null; then
-		local copy_cmd=( xclip -selection "$X_SELECTION" )
-		local paste_cmd=( xclip -o -selection "$X_SELECTION" )
+	elif [[ -n $DISPLAY ]]; then
+		if command -v xsel &> /dev/null; then
+			local copy_cmd=( xsel -i "--$X_SELECTION" )
+			local paste_cmd=( xsel -o "--$X_SELECTION" )
+		elif command -v xclip &> /dev/null; then
+			local copy_cmd=( xclip -selection "$X_SELECTION" )
+			local paste_cmd=( xclip -o -selection "$X_SELECTION" )
+		fi
 		local display_name="$DISPLAY"
+	elif command -v pbcopy &> /dev/null; then
+		local copy_cmd=( pbcopy )
+		local paste_cmd=( pbpaste )
+	elif command -v lemonade &> /dev/null; then
+		local copy_cmd=( lemonade copy )
+		local paste_cmd=( lemonade paste )
+	elif command -v doitclient &> /dev/null; then
+		local copy_cmd=( doitclient wclip )
+		local paste_cmd=( doitclient wclip -r )
+	elif command -v win32yank &> /dev/null; then
+		local copy_cmd=( win32yank -i --crlf )
+		local paste_cmd=( win32yank -o --lf )
+	elif command -v termux-clipboard-set &> /dev/null; then
+		local copy_cmd=( termux-clipboard-set )
+		local paste_cmd=( termux-clipboard-get )
+	elif command -v tmux &> /dev/null; then
+		local copy_cmd=( tmux load-buffer - )
+		local paste_cmd=(tmux save-buffer - )
 	else
-		die "Error: No X11 or Wayland display and clipper detected"
+		die "Error: No any clipper detected"
 	fi
 	local sleep_argv0="password store sleep on display $display_name"
 
-- 
2.38.1



More information about the Password-Store mailing list