Skip to content

Instantly share code, notes, and snippets.

@prenagha
Created January 13, 2014 15:17
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prenagha/8402107 to your computer and use it in GitHub Desktop.
Save prenagha/8402107 to your computer and use it in GitHub Desktop.
Launchbar action to create public gist
--
-- gist support for launchbar
-- 1. install gist client "sudo gem install gist"
-- https://github.com/defunkt/gist
-- 2. login "gist --login"
--
-- use from launchbar as file action, string/search action, or
-- plain action (will take text from clipboard)
-- then will put gist url as launchbar result
-- from there you can Copy it or hit Enter to open in browser
--
-- take string from LaunchBar and create public gist
on handle_string(theText)
try
set gistCmd to "echo " & quoted form of theText & " | gist"
set gistUrl to (do shell script gistCmd)
tell application "LaunchBar"
set selection as text to gistUrl
activate
end tell
on error e
tell application "LaunchBar" to display in large type "Error: " & e
end try
end handle_string
--take contents of a file (text) and create public gist
on open (theFile)
try
set pFile to (POSIX path of theFile) as text
set gistCmd to "cat " & quoted form of pFile & " | gist --filename " & quoted form of pFile
display dialog gistCmd
set gistUrl to (do shell script gistCmd)
tell application "LaunchBar"
set selection as text to gistUrl
activate
end tell
on error e
tell application "LaunchBar" to display in large type "Error: " & e
end try
end open
-- otherwise as straight action create public gist from clipboard
set clip to the clipboard
handle_string(clip)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment