Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 30, 2006, 12:00 PM   #1
hayduke
macrumors 65816
 
hayduke's Avatar
 
Join Date: Mar 2005
Location: is a state of mind.
Terminal command to move terminal window?

I'm a *bit* type-A about the location of my terminal windows. When I toggle between mirrored and dual display mode the terminal windows get bumped around (really annoying!) and I'd like to simple way to put them back where they belong. I have an alias that can resize the window (resize -s 24 80), but I can't figure out how to change the position. Thoughts?
hayduke is offline   0 Reply With Quote
Old Aug 30, 2006, 12:12 PM   #2
Shadow
macrumors 68000
 
Shadow's Avatar
 
Join Date: Feb 2006
Location: Keele, United Kingdom
Send a message via MSN to Shadow
Why not just drag them?
__________________
MacBook Pro 2.66GHz C2D 8GB 128GB SSD 9600m
iPhone 4 16GB
Shadow is offline   0 Reply With Quote
Old Aug 30, 2006, 12:19 PM   #3
hayduke
Thread Starter
macrumors 65816
 
hayduke's Avatar
 
Join Date: Mar 2005
Location: is a state of mind.
Sorry, you missed the part about me being type-A.

I can drag them, but I swap between mirrored and dual display frequently and its just kind of a pain to drag all five terminals back to their neat little homes.

I can resize them easily enough from the terminal and I bet some Unixy-savvy reader will have a suggestion for the pains that ail me.
hayduke is offline   0 Reply With Quote
Old Aug 30, 2006, 12:21 PM   #4
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
I'm fairly sure you can move a window (and resize it) from AppleScript. You could easily write a script that moves and resizes all your Terminal windows to where you want them...
robbieduncan is offline   0 Reply With Quote
Old Aug 30, 2006, 12:59 PM   #5
savar
macrumors 68000
 
savar's Avatar
 
Join Date: Jun 2003
Location: District of Columbia
Send a message via AIM to savar
Quote:
Originally Posted by hayduke
Sorry, you missed the part about me being type-A.

I can drag them, but I swap between mirrored and dual display frequently and its just kind of a pain to drag all five terminals back to their neat little homes.

I can resize them easily enough from the terminal and I bet some Unixy-savvy reader will have a suggestion for the pains that ail me.
With an XTerm I'll bet this is possible...but for Terminal.app? I doubt it.

I agree with the other poster. If positioning is important, write an AppleScript. You can always execute this script from the command line, if that's what you're concerned about.
__________________
Mehce
savar is offline   0 Reply With Quote
Old Aug 30, 2006, 01:27 PM   #6
hayduke
Thread Starter
macrumors 65816
 
hayduke's Avatar
 
Join Date: Mar 2005
Location: is a state of mind.
So here is an Applescript hack that works okay:

tell application "Terminal"
activate
set bounds of window 1 to {0, 0, 505, 320}
set bounds of window 2 to {0, 338, 505, 338 + 320}
set bounds of window 3 to {505, 0, 505 + 505, 320}
set bounds of window 4 to {505, 338, 505 + 505, 338 + 320}
set bounds of window 5 to {0, 338 + 338 - 20, 1010, 338 + 338 + 150}
end tell

The only trouble is that it will rearrange the windows because "window 1" is the most recently active window. Not sure if there is a way to do it based upon the window title, each of which contains "open apple"-# (eg open-apple 1 for the "first" window).

This works for now, but if there are other solutions, I'd be curious to hear them.
hayduke is offline   0 Reply With Quote
Old Aug 30, 2006, 02:51 PM   #7
kainjow
Moderator emeritus
 
kainjow's Avatar
 
Join Date: Jun 2000
I find it extremely annoying how all the windows get moved around when I switch from my 23" ACD to my MacBook's display. I just bought the ACD a few weeks ago and since it's summer I haven't had a need to take my MacBook around, but once school starts back up this Fall I'll be using it a lot and having to reposition all my windows every time will be very annoying. I wish there was a "global" solution to this but I don't think there is.

But on the topic of AppleScript.. you can assign names to your Terminal windows via Terminal (menu bar) > Window Settings, then choose Window from the popup button. Then you can refer to them in AppleScript like this:
Code:
set bounds of first window whose name starts with "blah" to {0, 0, 200, 200}
kainjow is offline   0 Reply With Quote
Old Aug 30, 2006, 02:54 PM   #8
Josh
macrumors 68000
 
Josh's Avatar
 
Join Date: Mar 2004
Location: State College, PA
If you were running X11 and eTerm, it is pretty simple and can be done via command.

You can also change their size, whether they have borders and control buttons, and their transparency from the command line.

But, that requires using a different terminal application :/
__________________
"Many go fishing all their lives without knowing that it is not fish they are after." - Thoreau
Josh is offline   0 Reply With Quote
Old Aug 30, 2006, 03:26 PM   #9
tedsmith3rd
macrumors member
 
Join Date: Aug 2006
Location: US
Terminal.app can do it too...

If you'd prefer to use the command line directly, Terminal.app can use xterm escape sequences too. I knocked a shell function out for your use with both moving and resizing Terminal windows. Add the code below to your .bash_profile or .profile. From then on in new terminal windows, you can type:

bumpNjump -x 10 -y 20 -w 800 -h 300

x and y are coordinates for the window;
w and h are width and height in pixels

The example above moves the window to 10,20 and sets the width to 800 and the height to 300. You don't have to set both the size and the position at the same time if you don't want to.

BTW, Bump 'n' Jump: greatest game ever.

Code:
function bumpNjump()
{
   local xDimension="" yDimension="" width="" height="" OPTIND

   while getopts 'x:y:w:h:' thisArg; do
      case "${thisArg}" in
         x) xDimension="${OPTARG}" ;;
         y) yDimension="${OPTARG}" ;;
         w) width="${OPTARG}" ;;
         h) height="${OPTARG}" ;;
      esac
   done

   if [ -n "${width}" -a -n "${height}" ]; then
      echo -en '\E[4;'${height}';'${width}'t';
   fi

   if [ -n "${xDimension}" -a -n "${yDimension}" ]; then
      echo -en '\E[3;'${xDimension}';'${yDimension}'t'
   fi
}
tedsmith3rd is offline   0 Reply With Quote
Old Aug 30, 2006, 05:27 PM   #10
savar
macrumors 68000
 
savar's Avatar
 
Join Date: Jun 2003
Location: District of Columbia
Send a message via AIM to savar
Quote:
Originally Posted by tedsmith3rd
If you'd prefer to use the command line directly, Terminal.app can use xterm escape sequences too. I knocked a shell function out for your use with both moving and resizing Terminal windows. Add the code below to your .bash_profile or .profile. From then on in new terminal windows, you can type:
Wow! Excellent catch
__________________
Mehce
savar is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming


Similar Threads
thread Thread Starter Forum Replies Last Post
UUID Command in Terminal? cdoolittle17 Mac Programming 3 Feb 28, 2014 01:54 PM
Mail command in Terminal lukestroh OS X Mavericks (10.9) 6 Dec 2, 2013 09:14 PM
Terminal command andynewfriends Mac Basics and Help 0 Jun 11, 2013 02:25 PM
run terminal command current finder window SniperUK Mac Applications and Mac App Store 3 Jul 30, 2012 02:52 PM
Need command in terminal chadteetzen OS X 1 Jun 8, 2012 11:55 PM

Forum Jump

All times are GMT -5. The time now is 04:55 AM.

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

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