0

I have a following script that I have been using for years to paste selection or a whole line from TextWrangler to R. I got it from some website, slightly modified, and it has worked perfectly:

tell application "TextWrangler"
set the_selection to (selection of front window as string)
if (the_selection) is "" then
    set the_selection to line (get startLine of selection) of front window as string
end if
end tell
tell application "R64"
cmd the_selection
end tell

Now I wanted to do the same, but pasting to Terminal window instead of R. However, when I modify the relevant line (3rd line from end) of the above script to:

tell application "Terminal"

the script no longer works. After some debugging I narrowed down the problem to the "cmd the_selection", where the editor says "Syntax error: Expected end of line but found identifier.". The funny thing is I cannot find what "cmd" command does - it's not in Apple's guidelines, and googling it doesn't help. I assume this must be some deprecated function to paste selection or line and that it no longer works in my version of applescript.

Any ideas how to fix this? cheers yot

1

Was cmd from R64's AppleScript dictionary or something?

You can run a command in Terminal with the do script verb.

tell application "Terminal"
    do script with command the_selection in window 1
end tell
  • Is the output something like this: tell application "TextWrangler" set the_selection to (selection of front window as string) if (the_selection) is "" then set the_selection to line (get startLine of selection) of front window as string end if end tell tell application "Terminal" do script with command the_selection in window 1 end tell ? – M. Beausoleil Jul 22 '16 at 18:06
  • I'm not really familiar with Applescripts. How do you send the selection to the terminal after selecting a line? You have to copy the script above in the TextWrangler's script folder and than run it from the menu script? – M. Beausoleil Jul 22 '16 at 18:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .