Skip to content

Instantly share code, notes, and snippets.

@shomah4a
Last active July 26, 2021 08:23
Show Gist options
  • Save shomah4a/d17425740c8b0b8b04fcacfef85090a9 to your computer and use it in GitHub Desktop.
Save shomah4a/d17425740c8b0b8b04fcacfef85090a9 to your computer and use it in GitHub Desktop.
wsl copy paste from windows clipboard
;; for wsl
(defun wsl-copy (start end)
(interactive "r")
(shell-command-on-region start end "clip.exe"))
(defun wsl-paste ()
(interactive "*")
(shell-command "powershell.exe -Command 'Get-Clipboard -Format Text' | sed s/\r//g" 1))
(advice-add 'clipboard-kill-ring-save :before #'wsl-copy)
(advice-add 'clipboard-kill-region :before #'wsl-copy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment