Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- utils = require 'mp.utils'
- function escape(s)
- return (s:gsub('\'', '\'\\\'\''))
- end
- function copy_sub()
- --windows copy taken from hsyong, github.com/mpv-player/mpv/issues/4695
- local escapedtext = string.gsub(mp.get_property("sub-text"), "'", "")
- local res = utils.subprocess({ args = {
- 'powershell', '-NoProfile', '-Command', string.format([[& {
- Trap {
- Write-Error -ErrorRecord $_
- Exit 1
- }
- Add-Type -AssemblyName PresentationCore
- [System.Windows.Clipboard]::SetText('%s')
- }]], escapedtext)
- } })
- end
- mp.add_key_binding("Ctrl+x", "copy_sub", copy_sub)
Advertisement