class Tmuxinator::Pane

Attributes

commands[R]
index[R]
project[R]
tab[R]
title[R]

Public Class Methods

new(index, project, tab, *commands, title: nil) click to toggle source
# File lib/tmuxinator/pane.rb, line 7
def initialize(index, project, tab, *commands, title: nil)
  @commands = commands
  @index = index
  @project = project
  @tab = tab
  @title = title.to_s.shellescape unless title.nil?
end

Public Instance Methods

last?() click to toggle source
# File lib/tmuxinator/pane.rb, line 60
def last?
  index == tab.panes.length - 1
end
name() click to toggle source
# File lib/tmuxinator/pane.rb, line 41
def name
  project.name
end
pane_index() click to toggle source
# File lib/tmuxinator/pane.rb, line 49
def pane_index
  index + tab.project.pane_base_index
end
tmux_main_command(command) click to toggle source
# File lib/tmuxinator/pane.rb, line 27
def tmux_main_command(command)
  if command
    _send_target(command.shellescape)
  else
    ""
  end
end
tmux_pre_command() click to toggle source
# File lib/tmuxinator/pane.rb, line 19
def tmux_pre_command
  _send_target(tab.pre.shellescape) if tab.pre
end
tmux_pre_window_command() click to toggle source
# File lib/tmuxinator/pane.rb, line 23
def tmux_pre_window_command
  _send_target(project.pre_window.shellescape) if project.pre_window
end
tmux_set_title() click to toggle source
# File lib/tmuxinator/pane.rb, line 35
def tmux_set_title
  unless title.nil?
    _set_title(title)
  end
end
tmux_split_command() click to toggle source
# File lib/tmuxinator/pane.rb, line 53
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_target() click to toggle source
# File lib/tmuxinator/pane.rb, line 15
def tmux_window_and_pane_target
  "#{project.name}:#{window_index}.#{pane_index}"
end
window_index() click to toggle source
# File lib/tmuxinator/pane.rb, line 45
def window_index
  tab.index + project.base_index
end

Private Instance Methods

_send_keys(target, keys) click to toggle source
# File lib/tmuxinator/pane.rb, line 70
def _send_keys(target, keys)
  "#{project.tmux} send-keys -t #{target} #{keys} C-m"
end
_send_target(keys) click to toggle source
# File lib/tmuxinator/pane.rb, line 66
def _send_target(keys)
  _send_keys(tmux_window_and_pane_target, keys)
end
_set_title(title) click to toggle source
# File lib/tmuxinator/pane.rb, line 74
def _set_title(title)
  target = tmux_window_and_pane_target
  "#{project.tmux} select-pane -t #{target} -T #{title}"
end