Module: Consular::ITermDSL

Defined in:
lib/consular/iterm_dsl.rb

Instance Method Summary collapse

Instance Method Details

#pane(*args, &block) ⇒ Object

Generates a pane in the terminal. These can be nested to create horizontal panes. Vertical panes are created with each top level nest.

Examples:


pane "top"
pane { pane "uptime" }

Parameters:

  • args (Array<String>)

    Array of comamnds

  • block (Proc)

    Block of code to execute in pane context.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/consular/iterm_dsl.rb', line 19

def pane(*args, &block)
  @_context[:panes] = {} unless @_context.has_key? :panes
  panes             = @_context[:panes]
  pane_name         = "pane#{panes.keys.size}"

  if block_given?
    pane_contents = panes[pane_name] = {:commands => []}
    if @_context.has_key? :is_top_pane
      run_context pane_contents[:commands], &block
    else
      pane_contents[:is_top_pane] = true
      run_context pane_contents, &block
    end
  else
    panes[pane_name] = { :commands => args }
  end
end