大道至簡

咦!錢塘江上潮信來,今日方知我是我。

How To Hack Wslg Clipboard

After setup wslg on my windows11, I use the wsl's emacs as my primay editor, the basic workflow most time is webbrowser(Google Chrome) on windows. Then coding on Emacs. The problem is the clipboard system not really working very well issue #15 github. So I did hack solution:

  1. create a command in wsl /usr/local/bin/wclip
  2. inset /mnt/c/path-to-pwsh.exe -NonInteractive -NoLogo -NoProfile -Command "get-clipboard -Raw"
  3. call wclip after copy something on windows

like for emacs

(defun get-windows-clipboard ()
  (interactive)
  (insert (s-replace "
" "" (shell-command-to-string "wclip"))))

it's slower than native way that for sure, but it works every time.