• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Scripting Terminal ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting Terminal ?


  • Subject: Re: Scripting Terminal ?
  • From: Christopher Stone <email@hidden>
  • Date: Fri, 17 Apr 2015 04:39:56 -0500

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

  • Follow-Ups:
    • Re: Scripting Terminal ?
      • From: Jean-Christophe Helary <email@hidden>
References: 
 >Scripting Terminal ? (From: Jean-Christophe Helary <email@hidden>)

  • Prev by Date: Re: AppleScript-Users Digest, Vol 12, Issue 175 message 2
  • Next by Date: Re: Scripting Terminal ?
  • Previous by thread: Scripting Terminal ?
  • Next by thread: Re: Scripting Terminal ?
  • Index(es):
    • Date
    • Thread