[PATCH] Add support for Windows clipboard (WSL)

Douglas Silva doug.hs at proton.me
Tue Oct 18 04:08:52 UTC 2022

Ok, now we're using the snapd method for detecting WSL, and I've tested your suggested "paste_cmd".

## paste_cmd
One problem. The Get-Clipboard cmdlet works as expected when you execute it from the shell, but not when called by pass. After 45 seconds the clipboard will still contain the copied password, with one addition: an empty newline. I couldn't yet figure out why.

## copy_cmd
I also tried to replace the older "clip.exe" with the Set-Clipboard cmdlet, but it only broke the functionality (clipboard stays empty).

Am I using these Powershell cmdlets wrong?

diff --git a/src/password-store.sh b/src/password-store.sh
index 22e818f..57d296d 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -155,7 +155,10 @@ check_sneaky_paths() {
 clip() {
-	if [[ -n $WAYLAND_DISPLAY ]] && command -v wl-copy &> /dev/null; then
+	if [[ -e "/proc/sys/fs/binfmt_misc/WSLInterop" ]]; then
+		local copy_cmd=( clip.exe )
+		local paste_cmd=( powershell.exe -Command Get-Clipboard )
+	elif [[ -n $WAYLAND_DISPLAY ]] && command -v wl-copy &> /dev/null; then
 		local copy_cmd=( wl-copy )
 		local paste_cmd=( wl-paste -n )
 		if [[ $X_SELECTION == primary ]]; then


More information about the Password-Store mailing list