Created
June 4, 2014 14:23
-
-
Save flegfleg/38d15763eb645c651f1b to your computer and use it in GitHub Desktop.
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
(* | |
modification of a file from: http://www.lawschoolmatt.com/workflows/taskpaper-tasks-with-finder-links | |
The code for copying a clickable link is from Petesh at Stack Overflow. http://stackoverflow.com/questions/9617029/how-to-get-the-a-file-url-in-osx-with-applescript-or-a-shell-script | |
*) | |
global sel | |
global PageLink | |
tell application "Finder" | |
set sel to the selection as text | |
set PageLink to "file:///" & my path2url(POSIX path of sel) | |
end tell | |
on path2url(thepath) | |
return do shell script "python -c \"import urllib, sys; print (urllib.quote(sys.argv[1]))\" " & quoted form of thepath | |
end path2url | |
set theSubject to the text returned of (display dialog "Task name: " default answer "Look at this file") | |
tell application "TaskPaper" | |
tell front document | |
tell project named "Inbox" | |
set newEntry to make new entry with properties {entry type:task type, text content:theSubject} | |
tell newEntry | |
-- make new entry with properties {entry type:note type, text content:theSubject} | |
make new entry with properties {entry type:note type, text content:"Link " & PageLink} | |
end tell | |
end tell | |
end tell | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment