Class: ItermWindow
- Inherits:
-
Object
- Object
- ItermWindow
- Defined in:
- lib/iterm_window.rb
Overview
The ItermWindow class models an iTerm terminal window and allows for full control via Ruby commands.
Defined Under Namespace
Classes: Tab
Instance Attribute Summary collapse
-
#tab_color_files ⇒ Object
readonly
Returns the value of attribute tab_color_files.
Class Method Summary collapse
- .colors ⇒ Object
- .colors=(colors) ⇒ Object
-
.current(&block) ⇒ Object
Selects the first terminal window, runs the block on it.
-
.open(options = {}, &block) ⇒ Object
Creates a new terminal window, runs the block on it.
- .run_file(file) ⇒ Object
Instance Method Summary collapse
- #concatenated_buffer ⇒ Object
- #default_tab(name, options = {}, &block) ⇒ Object
-
#initialize ⇒ ItermWindow
constructor
While you can directly use ItermWindow.new, using either ItermWindow.open or ItermWindow.current is the preferred method.
-
#open_bookmark(name, bookmark, &block) ⇒ Object
Creates a new tab from a bookmark, runs the block on it.
-
#open_tab(name, options = {}, &block) ⇒ Object
Creates a new tab from ‘Default Session’, runs the block on it.
-
#output(command) ⇒ Object
Outputs a single line of Applescript code.
- #run(window_type = :new, options = {}, &block) ⇒ Object
Constructor Details
#initialize ⇒ ItermWindow
While you can directly use ItermWindow.new, using either ItermWindow.open or ItermWindow.current is the preferred method.
96 97 98 99 100 101 |
# File 'lib/iterm_window.rb', line 96 def initialize @buffer = [] @tabs = {} @tab_color_files = [] @default_tab = nil end |
Instance Attribute Details
#tab_color_files ⇒ Object (readonly)
Returns the value of attribute tab_color_files.
74 75 76 |
# File 'lib/iterm_window.rb', line 74 def tab_color_files @tab_color_files end |
Class Method Details
.colors ⇒ Object
81 82 83 |
# File 'lib/iterm_window.rb', line 81 def colors @colors end |
.colors=(colors) ⇒ Object
77 78 79 |
# File 'lib/iterm_window.rb', line 77 def colors=(colors) @colors = colors end |
.current(&block) ⇒ Object
Selects the first terminal window, runs the block on it
113 114 115 |
# File 'lib/iterm_window.rb', line 113 def self.current(&block) self.new.run(:current, &block) end |
.open(options = {}, &block) ⇒ Object
Creates a new terminal window, runs the block on it
108 109 110 |
# File 'lib/iterm_window.rb', line 108 def self.open( = {}, &block) self.new.run(:new, , &block) end |
.run_file(file) ⇒ Object
103 104 105 |
# File 'lib/iterm_window.rb', line 103 def self.run_file(file) instance_eval(file) end |
Instance Method Details
#concatenated_buffer ⇒ Object
143 144 145 |
# File 'lib/iterm_window.rb', line 143 def concatenated_buffer @buffer.join("\n") end |
#default_tab(name, options = {}, &block) ⇒ Object
134 135 136 |
# File 'lib/iterm_window.rb', line 134 def default_tab(name, = {}, &block) open_tab(name, .merge(:default => true), &block) end |
#open_bookmark(name, bookmark, &block) ⇒ Object
Creates a new tab from a bookmark, runs the block on it
124 125 126 |
# File 'lib/iterm_window.rb', line 124 def open_bookmark(name, bookmark, &block) create_tab(name, bookmark, &block) end |
#open_tab(name, options = {}, &block) ⇒ Object
Creates a new tab from ‘Default Session’, runs the block on it
129 130 131 132 |
# File 'lib/iterm_window.rb', line 129 def open_tab(name, = {}, &block) create_tab(name, 'Default Session', , &block) @default_tab = name if [:default] end |
#output(command) ⇒ Object
Outputs a single line of Applescript code
139 140 141 |
# File 'lib/iterm_window.rb', line 139 def output(command) @buffer << command.gsub("'", '"').gsub('\\', '\\\\\\') end |
#run(window_type = :new, options = {}, &block) ⇒ Object
117 118 119 120 121 |
# File 'lib/iterm_window.rb', line 117 def run(window_type = :new, = {}, &block) @options = run_commands window_type, &block send_output end |