Last active
May 27, 2018 00:39
-
-
Save prenagha/8402640 to your computer and use it in GitHub Desktop.
run terminal command and return results directly back to launchbar
This file contains hidden or 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
-- | |
-- run terminal command and return results directly back to launchbar | |
-- runs command using applescript which means under /bin/sh | |
-- switches to user home dir before running script | |
-- | |
-- take string from LaunchBar and run as command | |
on handle_string(theText) | |
try | |
set cmd to "cd ~ && " & theText | |
set output to (do shell script cmd) | |
tell application "LaunchBar" | |
set selection as list to output | |
activate | |
end tell | |
on error e | |
tell application "LaunchBar" to display in large type "Error: " & e | |
end try | |
end handle_string | |
-- run as file as a script | |
on open (theFile) | |
try | |
set pFile to (POSIX path of theFile) as text | |
set cmd to "cd ~ && " & pFile | |
set output to (do shell script cmd) | |
tell application "LaunchBar" | |
set selection as list to output | |
activate | |
end tell | |
on error e | |
tell application "LaunchBar" to display in large type "Error: " & e | |
end try | |
end open | |
-- otherwise run whatever is in clipboard | |
-- enable this if you like, just be careful | |
--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
Thanks! I adapted the
open
version to run a specific shell script and do something with it.