Skip to content

Instantly share code, notes, and snippets.

@creativenull
Last active January 10, 2024 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creativenull/d1ddfd5c3964476c6f47f1384ead8b27 to your computer and use it in GitHub Desktop.
Save creativenull/d1ddfd5c3964476c6f47f1384ead8b27 to your computer and use it in GitHub Desktop.
ahk v2 script to copy txt file into clipboard for WSL
; Since I disable interop in WSL, this means I isolate my VM from Windows
; but copy pasting between WSL and Windows is also isolated.
; It's easier to copy from Windows to WSL via `Shift + Ins`
; but not easy to copy from WSL to Window, hence this autohotkey v2 script.
; Pressing `Win + V` will read a txt file that WSL can write to, and
; add to the clipboard. Save the old clipboard contents that I can
; still use `Ctrl + V` to paste the original copied content.
#v::
{
OldClipboard := ClipboardAll()
A_Clipboard := FileRead("C:\Users\<username>\_wsl_clipboard.txt")
Send "^v"
A_Clipboard := OldClipboard
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment