Skip to content

Commit

Permalink
use powershell for clipboard (#123)
Browse files Browse the repository at this point in the history
Switched to `powershell` to avoid text escape issues, and to remove the automatic newline.
  • Loading branch information
seth-js authored Apr 28, 2024
1 parent 59046e9 commit aeb451f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions platform/win.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ self.tmp_dir = function()
end

self.copy_to_clipboard = function(text)
text = text:gsub("&", "^^^&"):gsub("[<>|]", ""):gsub("\"", '')
mp.commandv("run", "cmd.exe", "/d", "/c", string.format("@echo off & chcp 65001 >nul & echo %s|clip", text))
mp.commandv("run", "powershell", "-command", string.format('Set-Clipboard -Value "%s"', text:gsub('"', '`"')))
end

self.curl_request = function(url, request_json, completion_fn)
Expand Down

0 comments on commit aeb451f

Please sign in to comment.