Last active
August 29, 2015 14:13
-
-
Save DrLulz/55f17beebaf79e781edd to your computer and use it in GitHub Desktop.
Copies selected text, converts to titlecase, and then pastes into OmniOutliner as new row. Comment out line 16 to keep focus on document from which text originates. Change "txt_capped" to "txt" on line 18 to disable titlecase convert. Use Alfred or other manager to link script to hotkey.
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
tell application "System Events" to keystroke "c" using {command down} | |
-- if OO document is minimized unminimize | |
tell application id "com.omnigroup.OmniOutliner4" | |
if miniaturized of front window is true then | |
set miniaturized of front window to false | |
end if | |
end tell | |
-- send clipboard text to handler | |
set txt to the clipboard as text | |
set txt_capped to titlecase(txt) | |
-- identify current row, make new row from clipboard, then select the new row | |
tell front document of application id "com.omnigroup.OmniOutliner4" | |
activate --comment out to keep focus on copied text | |
set parent_row to «class OOpa» of last «class OOsr» | |
make new «class OOrw» with properties {«class OOtp»:txt_capped} at end of parent_row -- change "txt_capped" to "txt" to remove titlecase | |
«event OTREisal» «class OO+s» of last «class OOsr» | |
end tell | |
-- capitalize first letter of each word | |
on titlecase(txt) | |
return do shell script "python -c \"import sys; print unicode(sys.argv[1], 'utf8').title().encode('utf8')\" " & quoted form of txt | |
end titlecase |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment