<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>@Lathi.net: Resizing Your Terminal</title>
    <link>http://blog.lathi.net/articles/2007/10/05/resizing-your-terminal</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>On Life, Fatherhood, Christianity, and Computers</description>
    <item>
      <title>Resizing Your Terminal</title>
      <description>&lt;p&gt;I thought I&amp;#8217;d go ahead and publish this because I found it useful (if ugly).  I do a lot of remote pair programming where my partner and I share a multi-user screen session inside a terminal.  It&amp;#8217;s very important that both partners have the same number of columns and rows visible.  Otherwise, whoever is smaller isn&amp;#8217;t going to see everything the other person sees and stuff jumps around and it&amp;#8217;s generally annoying.&lt;/p&gt;


	&lt;p&gt;So, the first thing that happens when you start a remote pairing session is you negotiate screen size.  I have my Apple Terminal.app set to show the screen size in the title bar as something like 105&amp;#215;54 or 94&amp;#215;71 or whatever.  So when my partner says, &amp;#8220;I can do 120&amp;#215;62 as my maximum size&amp;#8221; I have to click and drag my Terminal window until my size matches.  No more!&lt;/p&gt;


	&lt;p&gt;As I said above, this is pretty ugly but it works.  This shell script makes a one line applescript call through &lt;code&gt;osascript&lt;/code&gt; to tell the Terminal what size to make the window.  I put it in a shell script like this to simplify calling.  I started with a straight up applescript, but it was ugly to call it from the command line.  So I converted it to what you see here:&lt;/p&gt;


&lt;code&gt;
#!/bin/sh

/usr/bin/osascript -e 'tell application "Terminal"' -e "tell front window" -e "set the number of rows to $2" -e "set the number of columns to $1" -e "end tell" -e "end tell" 
&lt;/code&gt;

	&lt;p&gt;You can invoke it by simply saying:&lt;/p&gt;


&lt;code&gt;
$ resize_terminal 94 71
&lt;/code&gt;

	&lt;p&gt;and the front most Terminal window (likely the one you&amp;#8217;re typing in) will resize to 94 rows tall by 71 columns wide.&lt;/p&gt;</description>
      <pubDate>Fri, 05 Oct 2007 07:24:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:a5d3b52b-3319-44db-8cde-0e947458fb36</guid>
      <author>Doug</author>
      <link>http://blog.lathi.net/articles/2007/10/05/resizing-your-terminal</link>
      <category>Programming</category>
      <category>Mac OS X</category>
      <category>applescript</category>
      <category>macosx</category>
      <category>terminal</category>
      <category>osascript</category>
    </item>
    <item>
      <title>"Resizing Your Terminal" by Dave Minor</title>
      <description>&lt;p&gt;you&amp;#8217;re much more savvy than I, but my poor man&amp;#8217;s version:&lt;/p&gt;


	&lt;p&gt;right click -&amp;gt; window settings
select Window
set width/height
click in other window
set width/height&lt;/p&gt;</description>
      <pubDate>Fri, 05 Oct 2007 12:42:59 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:59efa506-fdef-4a8d-8a23-fad82a8844ae</guid>
      <link>http://blog.lathi.net/articles/2007/10/05/resizing-your-terminal#comment-388</link>
    </item>
    <item>
      <title>"Resizing Your Terminal" by Rob Biedenharn</title>
      <description>Or in ruby with the Ruby-OSA bridge:
&lt;pre&gt;&lt;code&gt;
begin
  require 'rubygems'
  require 'rbosa'
rescue LoadError
  puts "Unable to load 'rbosa', the Ruby-OSA bridge.\n  sudo gem install rbosa" 
  exit
end

term = OSA.app 'Terminal'

if frontwindow = term.windows.detect{|w|w.frontmost?}
  suppress_display = frontwindow.title_displays_window_size?
  if ARGV.size &amp;gt;= 2
    cols, rows = ARGV[0..1].map{|a|a.to_i}
    frontwindow.number_of_columns = cols
    frontwindow.number_of_rows    = rows
    suppress_display = false
  end
  puts "#{frontwindow.number_of_columns}x#{frontwindow.number_of_rows}" unless suppress_display
else
  puts "no frontmost window?" 
end
&lt;/code&gt;&lt;/pre&gt;</description>
      <pubDate>Fri, 05 Oct 2007 09:00:22 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:7fa7641c-84d7-497a-9638-fdec53d4f890</guid>
      <link>http://blog.lathi.net/articles/2007/10/05/resizing-your-terminal#comment-387</link>
    </item>
  </channel>
</rss>
