Created
January 13, 2014 15:17
Launchbar action to create public gist
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
-- | |
-- 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