#!/usr/local/bin/ruby # # This script is put in the public domain by Dav Yaginuma # You'll want to customize the terminals array and the project_path string require 'tempfile' require 'rubygems' require 'erubis' # much faster than erb, see http://www.rubyinside.com/advent2006/2-erubis.html unless ARGV.size==1 puts "specify project as parameter" exit end project = ARGV[0] project_path = "/Users/pivotal/dev/workspace/#{project}" unless File.exists?(project_path) puts "no such directory: #{project_path}" exit end # ############################### # Stick your terminal hashes here # ############################### terminals = [ { :title => "[#{project}: code]", :command => "cd #{project_path}", :columns => 176, :rows => 54, :x => 840, :y => 784 }, { :title => "[#{project}: mongrel]", :command => "cd #{project_path}; mongrel_rails start", :columns => 101, :rows => 15, :x => 2496, :y => -64 }, { :title => '[#{project}: selenium]', :command => "cd #{project_path}; rake selenium:server", :columns => 101, :rows => 15, :x => 1920, :y => -66 }, { :title => "[#{project}: development log]", :command => "cd #{project_path}; tail -n 500 -f log/development.log", :columns => 196, :rows => 41, :x => 1920, :y => 1296 }, { :title => "[#{project}: test log]", :command => "cd #{project_path}; tail -n 500 -f log/test.log", :columns => 196, :rows => 35, :x => 1920, :y => 693 }] class Terminal @@template_src = DATA.read @@template = Erubis::Eruby.new( @@template_src ) def initialize(attrs) @init_attrs = { :columns => 80, :rows => 25, :x => 0, :y => 0, :title =>"Terminal", :command => "", :font => "Monaco", :save_lines => 3000 }.merge(attrs) end def open term_filepath = Dir.tmpdir()+'/terminals.term' File.open(term_filepath, 'w') do |term_file| puts term_filepath p @init_attrs term_file.write @@template.result(@init_attrs) end system "open #{term_filepath}" end end terminals.each do |terminal| Terminal.new(terminal).open sleep 1 end __END__ WindowSettings AutoFocus YES Autowrap YES BackgroundImagePath Backwrap YES Bell YES BlinkCursor NO BlinkText YES CleanCommands rlogin;telnet;ssh;slogin Columns <%= columns %> CursorShape 0 CustomTitle <%= title %> DeleteKeySendsBackspace YES DisableAnsiColors NO DoubleBold YES DoubleColumnsForDoubleWide NO DoubleWideChars YES EnableDragCopy YES ExecutionString <%= command %> FontAntialiasing NO FontHeightSpacing 1 FontWidthSpacing 1 IsMiniaturized NO KeyBindings $F708 [25~ $F709 [26~ $F70A [28~ $F70B [29~ $F70C [31~ $F70D [22~ $F70E [33~ $F70F [34~ $F729  $F72B  $F72C [5~ $F72D [6~ F704 OP F705 OQ F706 OR F707 OS F708 [15~ F709 [17~ F70A [18~ F70B [19~ F70C [20~ F70D [21~ F70E [23~ F70F [24~ F710 [25~ F711 [26~ F712 [28~ F713 [29~ F714 [31~ F715 [32~ F716 [33~ F717 [34~ F728 [3~ F729 scrollToBeginningOfDocument: F72B scrollToEndOfDocument: F72C scrollPageUp: F72D scrollPageDown: ^F702  ^F703  ~F704 [17~ ~F705 [18~ ~F706 [19~ ~F707 [20~ ~F708 [21~ ~F709 [23~ ~F70A [24~ ~F70B [25~ ~F70C [26~ ~F70D [28~ ~F70E [29~ ~F70F [31~ ~F710 [32~ ~F711 [33~ ~F712 [34~ Meta -1 NSFixedPitchFont <%= font %> NSFixedPitchFontSize 10 OptionClickToMoveCursor NO PadBottom 3 PadLeft 5 PadRight 3 PadTop 3 RewrapOnResize YES Rows <%= rows %> SaveLines <%= save_lines %> ScrollRegionCompat NO ScrollRows 0 Scrollback YES Scrollbar YES Shell ShellExitAction 1 StrictEmulation NO StringEncoding 4 TermCapString vt102 TerminalOpaqueness 0.90499997138977051 TextColors 0.000 1.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 0.000 1.000 0.000 0.667 0.667 0.667 0.000 1.000 0.000 TitleBits 78 Translate YES UseCtrlVEscapes YES VisualBell NO WinLocULY <%= y %> WinLocX <%= x %> WinLocY 0 WindowCloseAction 1