From bbf86645d854ee39afa9afc20808775a59998742 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 12 Jul 2011 20:07:31 -0400 Subject: [PATCH] docs and move things around --- CHANGELOG.md | 6 ++ LICENSE | 3 +- README.md | 53 ++++++++++++++- README.rdoc | 72 --------------------- iterm_window.gemspec => itermwindow.gemspec | 4 +- 5 files changed, 61 insertions(+), 77 deletions(-) create mode 100644 CHANGELOG.md delete mode 100644 README.rdoc rename iterm_window.gemspec => itermwindow.gemspec (85%) diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a76db6f --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ +## 0.4.0 + +* Support `iTermfile` for easy per-project terminal definitions. +* Add tab coloring. +* Add options hashes to important blocks. + diff --git a/LICENSE b/LICENSE index 3b955d8..7b35e93 100644 --- a/LICENSE +++ b/LICENSE @@ -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. \ No newline at end of file +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 8faf685..d5bcb54 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/README.rdoc b/README.rdoc deleted file mode 100644 index 9dfe8a9..0000000 --- a/README.rdoc +++ /dev/null @@ -1,72 +0,0 @@ -= iTermWindow - -Developed March 17, 2008 by Chris Powers - -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 osascript 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 tab_color to change the color of the tab itself. Give it a hex value like F73 or F7F3F1. - diff --git a/iterm_window.gemspec b/itermwindow.gemspec similarity index 85% rename from iterm_window.gemspec rename to itermwindow.gemspec index 535fca5..052fb2a 100644 --- a/iterm_window.gemspec +++ b/itermwindow.gemspec @@ -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"