-
-
Save meain/07c4f5f2092593061bb57b3356527bc1 to your computer and use it in GitHub Desktop.
Command line tool, like `xclip -in -t text/html` for Mac. For preparing content for Google Docs/Sheets.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env swift | |
// Based on https://github.com/chbrown/macos-pasteboard/issues/8#issuecomment-906537204 | |
import Cocoa | |
import Foundation | |
let pasteboard: NSPasteboard = .general | |
let dataTypeName : String = "public.html" | |
let dataType = NSPasteboard.PasteboardType(rawValue: dataTypeName) | |
var text : String = "" | |
while let line = readLine() { | |
text += line | |
text += "\n" | |
} | |
let data = text.data(using: .utf8)! | |
pasteboard.clearContents() | |
pasteboard.setData(data, forType: dataType) | |
exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment