Add support for *clip.exe* for Bash on Ubuntu on Windows

Kenny Evitt kenny.evitt at gmail.com
Thu Apr 5 16:47:05 CEST 2018


I didn't submit a patch because I don't expect it be to merged upstream
anytime soon. The 'soft fork' is just a convenient place for me to keep the
changes where I, and anyone else, can access them.

Here's the patch for the changes (excluding my "soft fork" README changes):

---
 src/platform/linux.sh | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 src/platform/linux.sh

diff --git a/src/platform/linux.sh b/src/platform/linux.sh
new file mode 100644
index 0000000..93c568e
--- /dev/null
+++ b/src/platform/linux.sh
@@ -0,0 +1,27 @@
+# This file is actually for Bash on Ubuntu on Windows!
+
+clip() {
+ local sleep_argv0="password store sleep on display $DISPLAY"
+ pkill -f "^$sleep_argv0" 2>/dev/null && sleep 0.5
+ local before="$(read_from_clipboard | base64)"
+
+    write_to_clipboard "$(echo -n "$1")"
+ (
+ ( exec -a "$sleep_argv0" sleep "$CLIP_TIME" )
+ local now="$(read_from_clipboard | base64)"
+
+ [[ $now != $(echo "$1" | base64) ]] && before="$now"
+        write_to_clipboard "$(echo "$before" | base64 -d)"
+ ) 2>/dev/null & disown
+ echo "Copied $2 to clipboard. Will clear in $CLIP_TIME seconds."
+}
+
+read_from_clipboard() {
+    local
text="$(/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe
-Command "Add-Type -AssemblyName System.Windows.Forms;
[System.Windows.Forms.Clipboard]::GetText()")"
+    # Remove trailing carriage return:
+    echo "${text:0:-1}"
+}
+
+write_to_clipboard() {
+    /mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe -Command
"Add-Type -AssemblyName System.Windows.Forms;
[System.Windows.Forms.Clipboard]::SetText(\"$1\")"
+}
-- 
2.10.0.windows.1


On Wed, Apr 4, 2018 at 11:14 AM, Jason A. Donenfeld <Jason at zx2c4.com> wrote:

> Instead of a "soft fork", why not just submit proper patches to the
> mailing list to be reviewed and merged upstream? git-send-email is
> your friend.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20180405/6c79e2aa/attachment.html>


More information about the Password-Store mailing list