<feed xmlns="http://www.w3.org/2005/Atom" xmlns:foaf="http://xmlns.com/foaf/0.1/"><title>norman.walsh.name: Comments on /2007/08/27/macProgress</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2007/08/27/macProgress"/><id>http://norman.walsh.name/2007/08/27/macProgress/comments.atom</id><updated>2012-05-23T12:04:19.749785Z</updated><entry><title>Comment 1 on /2007/08/27/macProgress</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2007/08/27/macProgress#comment0001"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0001</id><published>2007-08-28T10:05:01Z</published><updated>2007-08-28T10:05:01Z</updated><author><name>Ceri Davies</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">Heh, I'm not sure that you really do want to know the equivalent of that!  As far as I've found, the only way to that is with one of open-x11(1), which doesn't seem to want to allow you to pass arguments, or AppleScript.

For AppleScript, you have to have a script, say usershell.scpt, that looks a little like:

<code></code><pre>
      <code>on run argv
	set server to item 1 of argv
	
	tell application "Terminal"
		activate
		with timeout of 10 seconds
			do script with command "ssh " &amp; server
			tell window 1
				set background color to "black"
				set cursor color to "green"
				set normal text color to "yellow"
				set bold text color to "red"
				set number of columns to 80
				set number of rows to 10
			end tell
		end timeout
	end tell
end run</code>
    </pre><code></code>

and then you run that with:

<code>osascript usershell.scpt hera</code>

Horrible, isn't it?</div></content></entry><entry><title>Comment 2 on /2007/08/27/macProgress</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2007/08/27/macProgress#comment0002"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0002</id><published>2007-08-28T11:53:57Z</published><updated>2007-08-28T11:53:57Z</updated><author><name>John Prevost</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">Hmm.  This lead me to try using #!/usr/bin/osascript to write a script, which... sadly, does not work.

You could, however, use a shell script combined with the following approach to do something moderately more powerful, using getopt and friends in sh.  Put that somewhere convenient, or in a shell function, even, and you now have a rather generic xterm-alike command.

<pre>
#!/bin/sh

# Smarter approach would be: parse out args using getopt and friends

bgcolor=$1
fgcolor=$2
width=$3
height=$4

shift 4

osascript &lt;&lt;__END__
on run argv
   tell application "Terminal"
      activate
      with timeout of 10 seconds
         do script with command "$*"
         tell window 1
            set background color to "$bgcolor"
            set normal text color to "$fgcolor"
            set number of columns to $width
            set number of rows to $height
         end tell
      end timeout
   end tell
end run
__END__
</pre></div></content></entry><entry><title>Comment 3 on /2007/08/27/macProgress</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2007/08/27/macProgress#comment0003"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0003</id><published>2007-08-28T13:01:49Z</published><updated>2007-08-28T13:01:49Z</updated><author><name>Norman Walsh</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">Thanks, Ceri! That moves "AppleScript" up on the list of things I must learn. In any event, that was the hint I needed. Here's what I cooked up:

<pre>#!/usr/bin/perl -- # -*- Perl -*-

use strict;
use Getopt::Long;
use English;

my $usage = "$0 [-bg color] [-fg color] [-geometry geom] [-e] command\n";

my $width = undef;
my $height = undef;
my $xofs = undef;
my $yofs = undef;
my $bgcolor = "white";
my $fgcolor = "black";
my $cucolor = "gray"; # FIXME: make this dynamic
my $bocolor = "red";  # FIXME: make this dynamic
my $command = "";
my $geometry = undef;

my $result = GetOptions ("bg=s"       =&gt; \$bgcolor,
                         "fg=s"       =&gt; \$fgcolor,
                         "geometry=s" =&gt; \$geometry,
                         "e=s"        =&gt; \$command);

die $usage unless $result;

if (defined($geometry)) {
    if ($geometry =~ /^(\d+)x(\d+)([\+\-]\d+)?([\+\-]\d+)?/) {
        $width = $1;
        $height = $2;
        $xofs = $3;
        $yofs = $4;
    } else {
        die "Invalid geometry: $geometry\n$usage";
    }
}

$bgcolor = getcolor($bgcolor);
$fgcolor = getcolor($fgcolor);
$cucolor = getcolor($cucolor);
$bocolor = getcolor($bocolor);

# FIXME: what about arguments that need to be quoted
$command .= " " if $command ne '';
$command .= join(' ', @ARGV);

open (SCRIPT, "| osascript -");
#open (SCRIPT, "&gt;-");
print SCRIPT "on run argv\n";
print SCRIPT "  set RGBfg to $fgcolor as RGB color\n";
print SCRIPT "  set RGBbg to $bgcolor as RGB color\n";
print SCRIPT "  set RGBcu to $cucolor as RGB color\n";
print SCRIPT "  set RGBbo to $bocolor as RGB color\n";
print SCRIPT "  tell application \"Terminal\"\n";
print SCRIPT "    activate\n";
print SCRIPT "    with timeout of 10 seconds\n";
print SCRIPT "      do script with command \"exec $command\"\n";
print SCRIPT "      tell window 1\n";
print SCRIPT "        set normal text color to RGBfg\n";
print SCRIPT "        set background color to RGBbg\n";
print SCRIPT "        set cursor color to RGBcu\n";
print SCRIPT "        set bold text color to RGBbo\n";
print SCRIPT "        set number of columns to $width\n"
    if defined($width);
print SCRIPT "        set number of rows to $height\n"
    if defined($height);
print SCRIPT "      end tell\n";
print SCRIPT "    end timeout\n";
print SCRIPT "  end tell\n";
print SCRIPT "end run\n";
close (SCRIPT);

sub getcolor {
    my $color = shift;
    my $db = "/usr/X11R6/lib/X11/rgb.txt";
    open (RGB, $db) || die "Cannot read color list: $db\n";
    my $match = (grep(/^\s*\d+\s+\d+\s+\d+\s+$color$/, ))[0];
    die "Unknown color: $color\n" if !defined($match);
    
    $match =~ /^(\d+)\s+(\d+)\s+(\d+)\s+/;

    my $r = int($1/255.0*65535.0);
    my $g = int($2/255.0*65535.0);
    my $b = int($3/255.0*65535.0);

    return "{$r,$g,$b}";
}</pre>

Bit of a hack, but gets the job done!</div></content></entry><entry><title>Comment 4 on /2007/08/27/macProgress</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2007/08/27/macProgress#comment0004"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0004</id><published>2007-08-28T13:03:25Z</published><updated>2007-08-28T13:03:25Z</updated><author><name>Norman Walsh</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Heh. Great minds, John :-)</p>
  </div></content></entry><entry><title>Comment 5 on /2007/08/27/macProgress</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2007/08/27/macProgress#comment0005"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0005</id><published>2007-08-28T15:06:15Z</published><updated>2007-08-28T15:06:15Z</updated><author><name>Curtis Pew</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>The way I do things like this, is to set up a Terminal window the way I want it to look, and then save it. When you do a save in Terminal, it allows you to specify a command to run instead of the default shell. Then the command line is:</p>
<pre>open <var>path-to-term-file</var></pre>
<p>If you save it into ~/Library/Application\ Support/Terminal it will appear in the "Library" item in Terminal’s File menu. Also, this file is an XML document (of sorts—I think it contains characters that aren’t legal in well-formed XML) and you can modify it with any text editor.</p>
  </div></content></entry><entry><title>Comment 6 on /2007/08/27/macProgress</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2007/08/27/macProgress#comment0006"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0006</id><published>2007-08-29T03:48:41Z</published><updated>2007-08-29T03:48:41Z</updated><author><name>Noah Slater</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>If you want an argument for the menu being attached to the top of the screen you should read up on Fitts' Law.
</p>
    <p>
http://en.wikipedia.org/wiki/Fitts'_law
</p>
    <p>
The top of the screen effectively makes the hight of the target area infinite and hence the time to acquirement is very low. You can literally <em>throw</em> your mouse upwards in the knowledge that it <em>will</em> land on the menu bar.</p>
  </div></content></entry><entry><title>Comment 7 on /2007/08/27/macProgress</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2007/08/27/macProgress#comment0007"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0007</id><published>2007-08-29T10:27:40Z</published><updated>2007-08-29T10:27:40Z</updated><author><name>Ceri Davies</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Nice, I'll update my scripts; never did get around to spending time on it.</p>
  </div></content></entry><entry><title>Comment 8 on /2007/08/27/macProgress</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2007/08/27/macProgress#comment0008"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0008</id><published>2007-08-29T12:19:50Z</published><updated>2007-08-29T12:19:50Z</updated><author><name>Wataru</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>As an alternative to click-to-focus, you can use F9 + [tab or cursor keys] to choose the focus from your keyboards.  If you use F10 it will give you the choice of windows within the application you are working on.</p>
  </div></content></entry><entry><title>Comment 9 on /2007/08/27/macProgress</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2007/08/27/macProgress#comment0009"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0009</id><published>2007-08-29T15:31:30Z</published><updated>2007-08-29T15:31:30Z</updated><author><name>Norman Walsh</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Hmm, Wataru. F9+[tab or cursor keys] has no effect on my desktop.</p>
  </div></content></entry><entry><title>Comment 10 on /2007/08/27/macProgress</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2007/08/27/macProgress#comment0010"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0010</id><published>2007-08-29T18:51:42Z</published><updated>2007-08-29T18:51:42Z</updated><author><name>Norman Walsh</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Oddly, Curtis, the "open /path/to/file.term" trick doesn't work for me. I fully expected it to, but in fact, nothing happens.</p>
  </div></content></entry><entry><title>Comment 11 on /2007/08/27/macProgress</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2007/08/27/macProgress#comment0011"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0011</id><published>2007-08-29T23:19:59Z</published><updated>2007-08-29T23:19:59Z</updated><author><name>Wataru</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Norman,  check "System Preferences --&gt; Dashboard &amp; Expose".  It has "Keyboard Shortcuts" section.  My setting for "All windows" is F9 and "Application windows" is F10.  I thought they were the default but maybe not.  Try the keys with your settings, they shoud work.</p>
  </div></content></entry><entry><title>Comment 12 on /2007/08/27/macProgress</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2007/08/27/macProgress#comment0012"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0012</id><published>2007-08-30T22:22:55Z</published><updated>2007-08-30T22:22:55Z</updated><author><name>Curtis Pew</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Hmm… at first I was worried because I'd never actually used <em>open</em> with a .term document (as a long time Mac user I’m pretty comfortable with a mouse, so I use the Library menu I mentioned) but to make sure I tried it and it worked for me. When you look at your .term documents in the Finder, does it say their type is "Terminal"? The other thing you might try is to use the Console utility to see if a message is being written there.</p>
  </div></content></entry><entry><title>Comment 13 on /2007/08/27/macProgress</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2007/08/27/macProgress#comment0013"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0013</id><published>2007-08-30T23:12:06Z</published><updated>2007-08-30T23:12:06Z</updated><author><name>Norman Walsh</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Hmm. Well, for whatever reason, it works today. But I swear it didn't yesterday. I have rebooted since then, but I can't say what really changed.</p>
  </div></content></entry><entry><title>Comment 14 on /2007/08/27/macProgress</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2007/08/27/macProgress#comment0014"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0014</id><published>2007-09-15T20:55:04Z</published><updated>2007-09-15T20:55:04Z</updated><author><name>Jean K.</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Hey Norm - I take it you got a MacBook since you were talking about the track pad.
</p>
    <p>
First thing I did when I got my Mac was set it to turn the track pad off when I've got a mouse up and running, and since I rarely take the silver surfboard anywhere, the track pad is pretty much always in disabled mode.
</p>
    <p>
My biggest trip up has been the need to use the fn key with all of the F keys and the Page direction keys.  so the first thing to try in the event of shortcut key failure is adding the fn key to the mix.
</p>
    <p>
Have you installed oXygen yet? I have to say, it looks gorgeous, and the screen geometry and functionality finally make sense to me!</p>
  </div></content></entry></feed>

