Class: Tmuxinator::Pane

Inherits:
Object show all
Defined in:
lib/tmuxinator/pane.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index, project, tab, *commands) ⇒ Pane

Returns a new instance of Pane.



5
6
7
8
9
10
# File 'lib/tmuxinator/pane.rb', line 5

def initialize(index, project, tab, *commands)
  @commands = commands
  @index = index
  @project = project
  @tab = tab
end

Instance Attribute Details

#commandsObject (readonly)

Returns the value of attribute commands.



3
4
5
# File 'lib/tmuxinator/pane.rb', line 3

def commands
  @commands
end

#indexObject (readonly)

Returns the value of attribute index.



3
4
5
# File 'lib/tmuxinator/pane.rb', line 3

def index
  @index
end

#projectObject (readonly)

Returns the value of attribute project.



3
4
5
# File 'lib/tmuxinator/pane.rb', line 3

def project
  @project
end

#tabObject (readonly)

Returns the value of attribute tab.



3
4
5
# File 'lib/tmuxinator/pane.rb', line 3

def tab
  @tab
end

Instance Method Details

#last?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/tmuxinator/pane.rb', line 53

def last?
  index == tab.panes.length - 1
end

#multiple_commands?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/tmuxinator/pane.rb', line 57

def multiple_commands?
  commands && commands.length > 0
end

#tmux_main_command(command) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/tmuxinator/pane.rb', line 34

def tmux_main_command(command)
  if command
    x = tab.index + project.base_index
    y = index + tab.project.base_index
    e = command.shellescape
    n = project.name
    "#{project.tmux} send-keys -t #{n}:#{x}.#{y} #{e} C-m"
  else
    ""
  end
end

#tmux_pre_commandObject



18
19
20
21
22
23
24
# File 'lib/tmuxinator/pane.rb', line 18

def tmux_pre_command
  return unless tab.pre

  t = tmux_window_and_pane_target
  e = tab.pre.shellescape
  "#{project.tmux} send-keys -t #{t} #{e} C-m"
end

#tmux_pre_window_commandObject



26
27
28
29
30
31
32
# File 'lib/tmuxinator/pane.rb', line 26

def tmux_pre_window_command
  return unless project.pre_window

  t = tmux_window_and_pane_target
  e = project.pre_window.shellescape
  "#{project.tmux} send-keys -t #{t} #{e} C-m"
end

#tmux_split_commandObject



46
47
48
49
50
51
# File 'lib/tmuxinator/pane.rb', line 46

def tmux_split_command
  path = if tab.root?
           "#{Tmuxinator::Config.default_path_option} #{tab.root}"
         end
  "#{project.tmux} splitw #{path} -t #{tab.tmux_window_target}"
end

#tmux_window_and_pane_targetObject



12
13
14
15
16
# File 'lib/tmuxinator/pane.rb', line 12

def tmux_window_and_pane_target
  x = tab.index + project.base_index
  y = index + project.base_index
  "#{project.name}:#{x}.#{y}"
end