2011-07-12 15:22:41 +00:00
# iTermWindow
*Make iTerm obey your command! Start up your complex development environment quickly and easily.*
The typical Rails project requires three or tour terminal windows/tabs open at once:
* The Rails app itself running using `rails s`
* Two continuous testing environments, powered by Guard or Autotest, running on your Ruby and JavaScript code
* A console ready for committing code or other maintenance tasks
* A log file or two
2011-07-13 00:07:31 +00:00
Opening all the necessary terminals, starting the right processes in each, and making them easily identifiable
is a long, slow process when done by hand. But guess what -- computers can be used to automate processes that
otherwise would be laborious when done manually!
2011-07-13 00:14:33 +00:00
Enter *iTermWindow* , a terminal window/tab multiplexer and command runner for Mac OS X and [iTerm ](http://www.iterm2.com/ ), the really
2011-07-13 00:07:31 +00:00
awesome Terminal.app replacement. iTerm's scriptability and customization allows one to create complex
project configurations for one's terminal setups.
2011-07-13 00:09:42 +00:00
## Installation
`gem install itermwindow` or add it to your Gemfile.
## Usage
2011-07-13 00:07:31 +00:00
The `iterm-window` executable will open and run an `iTermfile` file in the current directory.
An `iTermfile` file looks like this:
``` ruby
open :dir => Dir.pwd do
default_tab :console
open_tab :rails, :color => :rails do
2011-07-13 00:11:37 +00:00
rails "s"
2011-07-13 00:07:31 +00:00
end
open_tab :rspec, :color => :rspec do
guard "-g rspec"
end
open_tab :log, :color => "DDB" do
tail "+F -fr log/sphinx.log"
end
end
```
In a nutshell:
* `open` blocks open new iTerm windows.
* `current` blocks use the cirrent iTerm window.
* Inside `open` or `current` blocks you can open a new tab with `open_tab` .
* Specify a tab to be the selected tab with `default_tab` .
* Inside of a tab, you can write text into the terminal with `write_text` .
* Set the title of the tab with `set_title` .
* Or run a command magically (using `method_missing` ).
2011-07-13 00:10:49 +00:00
`open_tab` and `default_tab` can take an options hash:
2011-07-13 00:07:31 +00:00
* `:dir` changes to the given directory before executing commands.
* `:color` changes the window chrome and tab color to the given hex code (3 or 6 hex digits) or built-in color. See ItermWindow.colors for the list of available colors.
`open` can also take an options hash:
2011-07-13 00:10:26 +00:00
2011-07-13 00:07:31 +00:00
* `:dir` changes all tabs to the given directory before executing commands.
2011-07-13 14:22:13 +00:00
### Adding commands that tabs can execute
You can define your own tab commands with `ItermWindow.add_command` :
``` ruby
ItermWindow.add_command :guard do |group = nil|
command = "bundle exec guard"
command < < " -g #{group}" if group
write_text command
end
2011-07-13 14:25:35 +00:00
open do
default_tab do
guard :rails
end
end
2011-07-13 14:22:13 +00:00
```
2011-07-13 00:07:31 +00:00
More docs coming soon! Also, look at `lib/iterm_window.rb` for more usage examples.
2011-07-12 15:22:41 +00:00
* Developed March 17, 2008 by Chris Powers
2011-07-13 00:07:31 +00:00
* Extended June 2011 and beyond by John Bintz and (hopefully) many others
2011-07-12 15:22:41 +00:00