view lib/pmuxinator/pane.rb @ 2:67a6071afec7

Rename tmuxinator -> pmuxinator $ zmv **/*tmuxinator* **/*pmuxinator* $ gsed -e 's/tmuxinator/pmuxinator/g' -i **/*.* $ gsed -e 's/Tmuxinator/Pmuxinator/g' -i **/*.*
author Yasutaka Higa <e115763@ie.u-ryukyu.ac.jp>
date Mon, 21 Jul 2014 08:32:00 +0900
parents
children
line wrap: on
line source

module Pmuxinator
  class Pane
    attr_reader :commands, :project, :index, :project, :tab

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

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

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

    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

    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

    def tmux_split_command
      "#{project.tmux} splitw -t #{tab.tmux_window_target}"
    end

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

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