Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Applications > Mac Applications and Mac App Store

Thread Tools Search this Thread Display Modes
Old Nov 5, 2012, 09:37 PM   #1
macrumors newbie
Join Date: Nov 2012
Open Terminal With Specific Size And Location

I have used Unix/Linux for many years, recently on Mac hardware using VMWare to run Ubuntu. I am trying to make the switch to using the Mac OS "directly". I've got VIM working, my .bash_profile shell environment loading properly, command completion, command history editing using VI working, and so on. So far, so good.

One of the things I have done under Unix/Linux for years is have a script that opens several terminal windows of particular sizes at particular locations on a display. (I tend to work with VIM and other command line tools.) I would like to do the same in Mac OS.

I can see how to set up a "Terminal" with a particular name using the Mac OS GUI to have a certain number of rows, but what I want to do is have a script, (I assume it has to be an Applescript), that opens up several windows of different sizes at different locations.

I just don't see how you pass command line parameters to the "Terminal" application like you would with Gnome Shell, for example. For example, I have a bash script named "setupTerms2560x1600" which I will run when I have a 2560x1600 display to create a bunch of terminals of different sizes and different locations:

gnome-terminal --geometry=80x42+1+23 &
gnome-terminal --geometry=80x42+1901+23 &
gnome-terminal --geometry=80x42+1+800 &
gnome-terminal --geometry=80x42+1901+800 &
gnome-terminal --geometry=80x85+276+23 &
gnome-terminal --geometry=80x85+1000+23 &
gnome-terminal --geometry=80x85+1724+23 &

Am I trying to do something that Mac OS, or the Terminal application does not want me to do?

Should I install some other sort of Terminal application that is more Linux like? I tried out iTerm.

Is the verbose Applescript way of doing things the only way to set parameters of an application you are starting? For example, in the iTerm application help I see example Applescript like this:

-- reposition window and name it
set the bounds of the first window to {100, 100, 700, 700}
set the name of the first window to "A Window Title"

To me, it seems like I have to run the Applescript editor application to figure out what parameters I can set on an application.

And, in general, where I can search for these sorts of answers? (Besides this forum.) For example, I assume there are forums that ex-Windows programmers like to use because they can ask questions that make sense to people who are coming from a Windows background. I'm coming from a Unix/Linux background. Is there an applicable forum for us?

Thanks for any specific or general help.
sfordjasiri is offline   0 Reply With Quote
Old Nov 6, 2012, 02:15 PM   #2
macrumors G4
Weaselboy's Avatar
Join Date: Jan 2005
I think Applescript will do what you want with the "bounds" command.

tell application "Terminal"
    set bounds of window "Terminal" to {0, 0,1024, 768}
end tell
The first two numbers are horizontal and vertical positions of the top left corner, and the other two are the bottom right corner.

Weaselboy is offline   0 Reply With Quote
Old Nov 7, 2012, 10:26 PM   #3
Thread Starter
macrumors newbie
Join Date: Nov 2012
Found a solution

Thanks, your suggestion gave me the buzzwords I needed to find the answers I needed on some other websites. The script at the end of this posting shows how I did it, but I'm sure I am creating the Terminals in a funny way. Another solution I think is to simply use the Terminal application's Window->Save Windows As A Group... menu item to save the windows size and locations.

-- Create three Terminal windows.
-- The first Terminal is a tall window.
-- The second Terminal is medium height and is to
-- the tall Terminal's right.
-- The third Terminal is below the medium Terminal
-- and to the right of the tall Terminal.
tell application "Terminal"

-- Running the "clear" command seems to create a
-- new Terminal window, but I'm sure there is a
-- better way.
do script "clear"

-- Set the position/size of the Terminal window
-- we just created. Top left corner at x=40, y=40
-- and make its width 500 and height 1200 pixels.
-- Note that Mac OS menu bar uses about 20 pixels
-- of the top of the screen.
-- So, a Y position of 0 to 20 is hidden "under" the menu bar.
set the bounds of the front window to {40, 40, 539, 1239}

-- Open a medium sized Terminal window to the right of
-- the large window. Width = 500 pixels,
-- height = 800 pixels.
do script "clear"
set the bounds of the front window to {540, 40, 1039, 839}

-- Open a small Terminal window below the medium window.
do script "clear"
set the bounds of the front window to {540, 840, 1039, 1239}

end tell
sfordjasiri is offline   1 Reply With Quote

MacRumors Forums > Apple Applications > Mac Applications and Mac App Store

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -5. The time now is 05:10 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013,, LLC