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)


33
34
35
# File 'lib/tmuxinator/pane.rb', line 33

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

#multiple_commands?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/tmuxinator/pane.rb', line 37

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

#tmux_main_command(command) ⇒ Object



24
25
26
# File 'lib/tmuxinator/pane.rb', line 24

def tmux_main_command(command)
  command ? "#{project.tmux} send-keys -t #{project.name}:#{tab.index + project.base_index}.#{index + tab.project.base_index} #{command.shellescape} C-m" : ""
end

#tmux_pre_commandObject



16
17
18
# File 'lib/tmuxinator/pane.rb', line 16

def tmux_pre_command
  tab.pre ? "#{project.tmux} send-keys -t #{tmux_window_and_pane_target} #{tab.pre.shellescape} C-m" : ""
end

#tmux_pre_window_commandObject



20
21
22
# File 'lib/tmuxinator/pane.rb', line 20

def tmux_pre_window_command
  project.pre_window ? "#{project.tmux} send-keys -t #{tmux_window_and_pane_target} #{project.pre_window.shellescape} C-m" : ""
end

#tmux_split_commandObject



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

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

#tmux_window_and_pane_targetObject



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

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