This is either a bug or I'm doing something wrong. I've created a bundle command with the following line:
osascript -e 'tell application "TextMate"' -e 'set bounds of window 1 to {640, 1, 1279, 832}' -e 'set bounds of window 2 to {1, 1, 640, 832}' -e 'end tell';
TextMate beachballs until I run 'killall osascript' in the terminal. If I run the above line in the terminal directly, it works as expected. Is there some kind of break in the chain of Command -> Shell -> Applescript -> TextMate?
Can anybody think of a better way to emulate BBEdit's "Arrange Windows" command?
Thanks, Quinn
On Sat, 25 Mar 2006 21:29:35 -0800, Quinn Comendant wrote:
This is either a bug or I'm doing something wrong. I've created a bundle command with the following line:
osascript -e 'tell application "TextMate"' -e 'set bounds of window 1 to {640, 1, 1279, 832}' -e 'set bounds of window 2 to {1, 1, 640, 832}' -e 'end tell';
TextMate beachballs until I run 'killall osascript' in the terminal. If I run the above line in the terminal directly, it works as expected. Is there some kind of break in the chain of Command -> Shell -> Applescript -> TextMate?
I changed my command to redirect output to /dev/null and now it works!
osascript -e 'tell application "TextMate"' -e 'set bounds of window 1 to {640, 1, 1279, 832}' -e 'set bounds of window 2 to {1, 1, 640, 832}' -e 'end tell' &>/dev/null &
I'm not really sure WHY it works, but it does.
Can anybody think of a better way to emulate BBEdit's "Arrange Windows" command?
This still isn't an ideal script because it is SLOW. It takes 2 seconds for the windows to arrange themselves. I wonder if a compiled applescript would be faster? I've never done much applescript work hmmmm...
Q
On 26/3/2006, at 9:18, Quinn Comendant wrote:
TextMate beachballs until I run 'killall osascript' [...]
I changed my command to redirect output to /dev/null and now it works! [...] I'm not really sure WHY it works, but it does.
If you do not redirect stdout/error, it will be inherited by the parent process (which TM waits for), and then that parent will not be able to exit.
[...] This still isn't an ideal script because it is SLOW. It takes 2 seconds for the windows to arrange themselves. I wonder if a compiled applescript would be faster?
Maybe twice as fast. If I do:
time osascript -e 'return current date'
Then the real time spent is .2s on my 2.5 GHz Dual G5. Compare that e.g. to:
time ruby -e 'p Time.now'
Which takes 0.01s on the same machine. The main time spent with AS though seems to be initialization.
I wonder if a compiled applescript would be faster?
Maybe twice as fast. [...]
I've tried saving the applescript as a compiled application, but the execution time is still about 2 seconds. However, I notice if I save the same script and execute it from the Script Menu in the menu bar (via AppleScript Utility) or directly on the command line (via osascript) the applescript window arrangement commands run almost instantly. Where's the bottleneck?
Quinn
On 26/3/2006, at 22:30, Quinn Comendant wrote:
I wonder if a compiled applescript would be faster?
Maybe twice as fast. [...]
I've tried saving the applescript as a compiled application, but the execution time is still about 2 seconds. However, I notice if I save the same script and execute it from the Script Menu in the menu bar (via AppleScript Utility) or directly on the command line (via osascript) the applescript window arrangement commands run almost instantly. Where's the bottleneck?
Maybe it’s the shell startup then. Try to type “date” in a new document and press ctrl-R to see how long that takes.
The shell startup is described here [1]. It might be you have a lot of stuff going on which is only necessary for an interactive shell (for example Fink sets up a lot of completion configuration in /etc/ profile iirc).
You could skip it by changing the command e.g. to:
#!/bin/sh osascript «script»
But you may still want to tune your shell startup, as it’s used for a lot of functionality in TM.
[1] http://macromates.com/textmate/manual/shell_commands#search_path
On 28/3/2006, at 4:38, Quinn Comendant wrote:
That was it...MUCH faster. Yes, my bash startup is slow. I'm not using fink, but have a few dozen functions in my .bashrc.
You may want to wrap it in something like:
if [[ $- == *i* ]]; then ...all your functions and stuff... fi
Then only when the shell is interactive, will it run the stuff.
You may want to wrap it in something like:
if [[ $- == *i* ]]; then ...all your functions and stuff... fi
That works great, thanks.
A (maybe) related question:
For me the Diff bundle's "Document With Clipboard" command takes over 35 seconds (even with a short document of a few lines). Then then results are wrong anyways (it shows all lines removed).
Anybody else have this problem?
Quinn
On 29/3/2006, at 3:21, Quinn Comendant wrote:
For me the Diff bundle's "Document With Clipboard" command takes over 35 seconds (even with a short document of a few lines). Then then results are wrong anyways (it shows all lines removed).
Anybody else have this problem?
That’s a deadlock which stems from TM being the clipboard owner when pbpaste is executed.
The current workaround is to install Quicksilver’s clipboard module (so QS will always be the owner) -- of course long-term it won’t be necessary to rely on such 3rd party modules, but it’s a little out in the future.