Guest User

Untitled

a guest
Feb 18th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. tell application "System Events"
  2. try
  3. set callingEditor to 1st process whose name is "TextWrangler" or name is "BBEdit"
  4. on error
  5. tell me to quit
  6. end try
  7. set appName to the name of callingEditor
  8. end tell
  9.  
  10. set tmpFile to ""
  11.  
  12. tell application appName
  13. using terms from application "BBEdit"
  14. set numdocs to the number of every text document
  15.  
  16. end using terms from
  17. end tell
  18.  
  19.  
  20. if numdocs > 0 then
  21. tell application appName
  22. using terms from application "BBEdit"
  23. set myText to get text of active document of window 1
  24. end using terms from
  25. end tell
  26. set randomNumber to random number from 1 to 1000
  27. set tmpFile to "/tmp/relnote-" & randomNumber & ".mdown"
  28. set theFileReference to open for access tmpFile with write permission
  29. write myText to theFileReference
  30. close access theFileReference
  31.  
  32. set home to do shell script "echo $HOME"
  33. set relnote to do shell script "source " & (the quoted form of POSIX path of home) & "/.profile && which relnote"
  34. set cmd to relnote & " " & (the quoted form of POSIX path of tmpFile)
  35. do shell script cmd
  36. end if
Add Comment
Please, Sign In to add comment