The window bounds are a list of coordinates {left, top, right, bottom}. You probably intended "400" to be the width, but it's the position of the right edge of the window and 400 is to the left of 1105, so you get a minimum width window. Change 400 to 1105 plus the desired width, e.g., 1505.
But before you pursue this further, Terminal has a better solution for this: Window Groups. If you set up a group of windows and save them as a Window Group, each time you open that group it will create windows with the same layout and appearance.
Window > Save Windows as Group…
You can even tell Terminal to open a selected window group at startup:
Terminal > Preferences > Startup > On startup, open: > Window group:
(As a shortcut, when creating a window group there's a checkbox for making it the startup group.)
To automatically run particular commands in those windows, you can create custom settings profiles and specify the command with
Terminal > Preferences > Settings > [profile] > Shell > Startup > Run command:
then create each window with the appropriate profile.
Going further, in Mac OS X Lion 10.7 you can have window groups automatically restore commands without creating custom profiles, by creating the terminals using
Shell > New Command
instead of running the command inside the terminal shell. When creating the window group, you can check "Restore all commands". (By default, it will restore a small set of "safe" commands, but you must explicitly tell it if you want it to re-run all commands when opening the group.)
Moreover, Lion Terminal supports Resume and will automatically restore all your windows each time you open Terminal. It will even restore "safe" commands for terminals created with New Command.
The problem you are having with Gitbox is because not all application are scriptable. Which means you cannot talk to it via applescript. What you can do for apps like that is use System Events to do some of it for you.
*Check if scriptable *
set theApp to "Gitbox"
tell application "System Events"
set isScriptable to has scripting terminology of application process theApp
if isScriptable then
my scriptableApp(theApp)
else
my nonScriptableApp(theApp)
end if
end tell
on scriptableApp(theApp)
tell application theApp to get the bounds of the front window
end scriptableApp
on nonScriptableApp(theApp)
tell application "System Events"
set the props to get the properties of the front window of application process theApp
set theSBounds to {size, position} of props
end tell
end nonScriptableApp
Get the bounds via system events
#get the bounds via system events
tell application "System Events"
set the props to get the properties of the front window of application process "Gitbox"
set theSBounds to {size, position} of props
end tell
Set the bounds via system events
--set theSBounds to {{799, 490}, {513, 430}} #This is a test line that will set the bounds list so you can see the set bound code working un comment to use it
#set the bounds via system events
tell application "System Events"
set size of front window of application process "Gitbox" to item 1 of theSBounds
set position of front window of application process "Gitbox" to item 2 of theSBounds
end tell
Best Answer
It seems that TextEdit hardcodes the position for new document windows, and it's not possible to tweak this behaviour using
defaults write
to modify TextEdit's Preferences. See this old post from Apple Discussions:To change the default position of new TextEdit documents there's really only one solution: write a custom AppleScript that can open a new document at your preferred location centered on the screen.