• 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
Tabs in Terminal.app on Leopard
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Tabs in Terminal.app on Leopard


  • Subject: Tabs in Terminal.app on Leopard
  • From: "Matthew Lambie" <email@hidden>
  • Date: Thu, 1 Nov 2007 13:42:45 +0900

Hi everyone,

I thought rather than mix in Apple Script and pseudocode together I'd
just post my pseudocode - I hope that's OK. Via Google I've learnt how
to tell Terminal to run a script, so it's more the case of opening new
tabs and checking for focus.

I have two main issues:
- Can you "name" windows via Applescript?
- How do you launch a new tab within Terminal?

For example, I've found this script which will open a Terminal (or use
the first available non-busy Terminal), obtain focus and execute a
command (uptime):

property commandString : "/usr/bin/uptime" -- < Edit this line as desired.

tell application "Terminal" -- Get a free window to run the commandString,
	activate -- (being sure to avoid creating a new session unnecessarily,
	-- while also handling the possibility that frontmost window is busy):
	set windowCount to (count of the windows)
	if windowCount is greater than 0 then
		repeat with w from 1 to windowCount
			if window 1 is busy then
				set frontmost of window 1 to false
			else
				do script commandString in window 1
				set frontmost of window 1 to true
				return
			end if
		end repeat
	end if
	tell window 1
		do script commandString
		set frontmost to true
	end tell
end tell

(script via : http://forums.macosxhints.com/showthread.php?p=359524)

I want to perform the following (pseudocode) with Terminal - can
anyone help me out?:

server_name = "SERVER_NAME"
Open Terminal
if a window called server_name exists
    give it focus
else
    create a new window
    name this window server_name
    for i = 1 to 4
        create a new tab
        execute a command (ssh server_name)
    end for
end

The idea is that I'll click an icon and it opens Terminal up, opens 4
tabs and in each tab performs an ssh to SERVER_NAME (and opens a
screen session). Ideally, I'd like to test if the window already
exists and if it does, give it focus. This will prevent the screen
sessions from being "dropped" in the original window and opening again
in the new window, if it exists.

I'd also like to attach the scripts to individual icons, so I can
click on hotrod, prime, soundwave or any other cool Transformers icon
that I have in my dock to represent our servers.

Thanks so much - I'm loving Leopard and Terminal's tabs... I just want
some automation!

Matt Lambie
http://lambie.org
 _______________________________________________
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

  • Prev by Date: Re: [Slightly OT] Scripting Bridge in Leopard
  • Previous by thread: Re: [Slightly OT] Scripting Bridge in Leopard
  • Index(es):
    • Date
    • Thread