Skip to content

Instantly share code, notes, and snippets.

@hyuki
Created June 7, 2018 08:00
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 hyuki/0ead100dbfaa3a40c11423279ff9744e to your computer and use it in GitHub Desktop.
Save hyuki/0ead100dbfaa3a40c11423279ff9744e to your computer and use it in GitHub Desktop.
ulysses-import - Import a given text to Ulysses.
#!/usr/bin/env ruby
# encoding: utf-8
# https://ulyssesapp.com/kb/x-callback-url/
require 'uri'
FORMAT = 'text' # html, markdown
GROUP = URI.escape('Imported Text')
if ARGV.length == 0
puts "Usage: ulysses-import textfile.txt"
abort
end
text = URI.escape(IO.readlines(ARGV[0]).join)
system(%Q(open "ulysses://x-callback-url/new-sheet?text=#{text}&group=#{GROUP}&format=#{FORMAT}&index=0"))
@hyuki
Copy link
Author

hyuki commented Jun 7, 2018

$ cat sample.txt
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
$ ulysses-import sample.txt

20180607165938

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment