docs and move things around

This commit is contained in:
John Bintz 2011-07-12 20:07:31 -04:00
parent 9ad331f7ca
commit bbf86645d8
5 changed files with 61 additions and 77 deletions

6
CHANGELOG.md Normal file
View File

@ -0,0 +1,6 @@
## 0.4.0
* Support `iTermfile` for easy per-project terminal definitions.
* Add tab coloring.
* Add options hashes to important blocks.

View File

@ -1,4 +1,5 @@
Copyright (c) 2009 Chris Powers
Copyright (c) 2011 John Bintz
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
@ -17,4 +18,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -9,6 +9,55 @@ The typical Rails project requires three or tour terminal windows/tabs open at o
* A console ready for committing code or other maintenance tasks
* A log file or two
* Developed March 17, 2008 by Chris Powers
* Extended June 2011 and beyond by John Bintz and many others
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!
Enter *iTermWindow*, a terminal window/tab multiplexer and command runner for Mac OS X and iTerm, the really
awesome Terminal.app replacement. iTerm's scriptability and customization allows one to create complex
project configurations for one's terminal setups.
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
guard "-g rails"
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`).
`open_tab`, and `default_tab` can take an options hash:
* `: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:
* `:dir` changes all tabs to the given directory before executing commands.
More docs coming soon! Also, look at `lib/iterm_window.rb` for more usage examples.
* Developed March 17, 2008 by Chris Powers
* Extended June 2011 and beyond by John Bintz and (hopefully) many others

View File

@ -1,72 +0,0 @@
= iTermWindow
<em>Developed March 17, 2008 by Chris Powers</em>
The ItermWindow class models an iTerm terminal window and allows for full control via Ruby commands.
Under the hood, this class is a wrapper of iTerm's Applescript scripting API. Methods are used to
generate Applescript code which is run as an <tt>osascript</tt> command when the ItermWindow initialization
block is closed.
ItermWindow::Tab models a tab (session) in an iTerm terminal window and allows for it to be controlled by Ruby.
These tabs can be created with either the ItermWindow#open_bookmark method or the ItermWindow#open_tab
method. Each tab is given a name (symbol) by which it can be accessed later in the code using
the tab name as an ItermWindow method.
== EXAMPLE - Open a new iTerm window, cd to a project and open it in TextMate
require 'rubygems'
require 'chrisjpowers-iterm_window'
ItermWindow.open do
open_tab :my_tab do
write "cd ~/projects/my_project/trunk"
write "mate ./"
end
end
== EXAMPLE - Use the current iTerm window, cd to a project and open in TextMate, launch the server and the console and title them
ItermWindow.current do
open_tab :project_dir do
write "cd ~/projects/my_project/trunk"
write "mate ./"
set_title "MyProject Dir"
end
open_tab :server do
write "cd ~/projects/my_project/trunk"
write "script/server -p 3005"
set_title "MyProject Server"
end
open_tab :console do
write "cd ~/projects/my_project/trunk"
write "script/console"
set_title "MyProject Console"
end
end
== EXAMPLE - Same thing, but use bookmarks that were made for the server and console. Also, switch focus back to project dir.
ItermWindow.current do
open_tab :project_dir do
write "cd ~/projects/my_project/trunk"
write "mate ./"
end
open_bookmark :server, 'MyProject Server'
open_bookmark :console, 'MyProject Console'
project_dir.select
== EXAMPLE - Arbitrarily open two tabs, switch between them and run methods/blocks with Tab#select method and Tab#write directly
ItermWindow.open do
open_tab :first_tab
open_tab :second_tab
first_tab.select do
write 'cd ~/projects'
write 'ls'
end
second_tab.write "echo 'hello there!'"
first_tab.select # brings first tab back to focus
end
Also, you get <tt>tab_color</tt> to change the color of the tab itself. Give it a hex value like <tt>F73</tt> or <tt>F7F3F1</tt>.

View File

@ -1,12 +1,12 @@
Gem::Specification.new do |s|
s.name = 'iterm_window'
s.name = 'itermwindow'
s.version = '0.4.0'
s.authors = [ 'Chris Powers', 'John Bintz' ]
s.date = Time.now
s.homepage = 'http://github.com/johnbintz/iterm_window'
s.email = [ 'chrisjpowers@gmail.com', 'john@coswellproductions.com' ]
s.summary = 'The ItermWindow class models an iTerm terminal window and allows for full control via Ruby commands.'
s.files = ['README.rdoc', 'LICENSE', 'lib/iterm_window.rb']
s.files = ['README.md', 'LICENSE', 'CHANGELOG.md', 'lib/iterm_window.rb']
s.require_paths = ["lib"]
s.has_rdoc = true
s.executables << "iterm-window"