Re: Scripting Terminal ?
Re: Scripting Terminal ?
- Subject: Re: Scripting Terminal ?
- From: Jean-Christophe Helary <email@hidden>
- Date: Fri, 17 Apr 2015 21:10:02 +0900
Christopher,
Thank you very much for the obvious pointer. I'll be making a Service to automatically check the list with problematic strings in the future :)
What I was trying to do today was:
- select a few files in Finder
- send them to Automator (to package that as a service)
- process them with an Applescript that creates a new window with as many tabs as there are files and open each file in an emacs session
What I can do is open as many Terminal windows as there are files, but that's not elegant.
I've already spent undue hours trying to make tabs and windows with "make new" and even with the scripts referenced below (and those I found on the web) I'm not progressing much...
Jean-Christophe
> On Apr 17, 2015, at 18:39, Christopher Stone <email@hidden> wrote:
>
> On Apr 17, 2015, at 04:00, Jean-Christophe Helary <email@hidden> wrote:
>> I'm having trouble with the notions of "window" and "tab" in Terminal.
>> …
>> What is the mystery behind tabs and windows in Terminal scripting ?
> ______________________________________________________________________
>
> Hey Jean-Christophe,
>
> Remember that you can use Google to search the list:
>
> tell application '"Terminal"' site:http://lists.apple.com/archives/applescript-users
>
> Appended are a few examples.
>
> --
> Best Regards,
> Chris
>
> -------------------------------------------------------------------------------------------
> # Auth: Christopher Stone
> # dCre: 2015/02/10 14:36
> # dMod: 2015/04/17 04:33
> # Appl: Terminal
> # Task: Open a new window in Terminal.
> # Libs: None
> # Osax: None
> # Tags: @Applescript, @Script, @Terminal, @Open, @New, @Window
> -------------------------------------------------------------------------------------------
>
> tell application "Terminal"
> if not (exists window 1) then
> reopen
> else
> do script ""
> end if
> end tell
>
> -------------------------------------------------------------------------------------------
>
>
> -------------------------------------------------------------------------------------------
> # Auth: Christopher Stone
> # dCre: 2015/03/10 11:37
> # dMod: 2015/04/17 04:35
> # Appl: Terminal
> # Task: Run a Script in the active tab of the front window.
> # Libs: None
> # Osax: None
> # Tags: @Applescript, @Terminal, @Run, @Script, @Active, @Tab
> -------------------------------------------------------------------------------------------
>
> set _dir to POSIX path of (path to downloads folder)
>
> tell application "Terminal"
> activate
> tell front window
> if busy = false then
> set shCMD to "'ls' -lp " & _dir
> do script shCMD in selected tab
> end if
> end tell
> end tell
>
> -------------------------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------------------------
> # Auth: Christopher Stone
> # dCre: 2011/10/16 02:11
> # dMod: 2012/08/28 00:55
> # Appl: Finder, Terminal
> # Task: CD to Front Finder Window's Directory.
> # Libs: None
> # Osax: None
> # Tags: @Applescript, @Terminal, @CD, @Front, @Finder, @Window
> ------------------------------------------------------------------------------------------
>
> try
>
> tell application "Finder"
> if (count of windows) > 0 then
> set winTarget to target of front window as alias
> else
> set winTarget to path to desktop
> end if
> end tell
>
> set winTarget to quoted form of (POSIX path of winTarget)
>
> tell application "Terminal"
> if (busy of front window) = true then
> do script "cd " & winTarget
> else if (busy of front window) = false then
> tell front window
> do script "cd " & winTarget in selected tab
> end tell
> end if
> end tell
>
> on error eMsg number eNum
> tell me to display dialog eMsg & return & return & eNum
> end try
>
> ------------------------------------------------------------------------------------------
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden