class Tmuxinator::Window
Attributes
Public Class Methods
Source
# File lib/tmuxinator/window.rb, line 9 def initialize(window_yaml, index, project) first_key = window_yaml.keys.first @name = first_key.to_s.shellescape unless first_key.nil? @yaml = window_yaml.values.first @project = project @index = index @commands = build_commands(tmux_window_command_prefix, @yaml) end
Public Instance Methods
Source
# File lib/tmuxinator/window.rb, line 51 def _project_root project.root if project.root? end
Source
# File lib/tmuxinator/window.rb, line 72 def build_commands(_prefix, command_yml) if command_yml.is_a?(Array) command_yml.map do |command| "#{tmux_window_command_prefix} #{command.shellescape} C-m" if command end.compact elsif command_yml.is_a?(String) && !command_yml.empty? ["#{tmux_window_command_prefix} #{command_yml.shellescape} C-m"] else [] end end
Source
# File lib/tmuxinator/window.rb, line 55 def build_panes(panes_yml) return if panes_yml.nil? Array(panes_yml).map.with_index do |pane_yml, index| commands, title = case pane_yml when Hash [pane_yml.values.first, pane_yml.keys.first] when Array [pane_yml, nil] else [pane_yml, nil] end Tmuxinator::Pane.new(index, project, self, *commands, title: title) end.flatten end
Source
# File lib/tmuxinator/window.rb, line 31 def layout yaml["layout"] ? yaml["layout"].shellescape : nil end
Source
# File lib/tmuxinator/window.rb, line 19 def panes build_panes(yaml["panes"]) || [] end
Source
# File lib/tmuxinator/window.rb, line 84 def pre _pre = yaml["pre"] if _pre.is_a?(Array) _pre.join(" && ") elsif _pre.is_a?(String) _pre end end
Source
# File lib/tmuxinator/window.rb, line 41 def root return _project_root unless _yaml_root File.expand_path(_yaml_root, _project_root).shellescape end
The expanded, joined window root path Relative paths are joined to the project root
Source
# File lib/tmuxinator/window.rb, line 35 def synchronize yaml["synchronize"] || false end
Source
# File lib/tmuxinator/window.rb, line 145 def synchronize_after? synchronize == "after" end
Source
# File lib/tmuxinator/window.rb, line 141 def synchronize_before? synchronize == true || synchronize == "before" end
Source
# File lib/tmuxinator/window.rb, line 133 def tmux_layout_command "#{project.tmux} select-layout -t #{tmux_window_target} #{layout}" end
Source
# File lib/tmuxinator/window.rb, line 120 def tmux_new_window_command path = root? ? "#{Tmuxinator::Config.default_path_option} #{root}" : nil "#{project.tmux} new-window #{path} -k -t #{tmux_window_target} #{tmux_window_name_option}" end
Source
# File lib/tmuxinator/window.rb, line 106 def tmux_pre_window_command return unless project.pre_window "#{project.tmux} send-keys -t #{tmux_window_target} #{project.pre_window.shellescape} C-m" end
Source
# File lib/tmuxinator/window.rb, line 137 def tmux_select_first_pane "#{project.tmux} select-pane -t #{tmux_window_target}.#{panes.first.index + project.pane_base_index}" end
Source
# File lib/tmuxinator/window.rb, line 129 def tmux_synchronize_panes "#{project.tmux} set-window-option -t #{tmux_window_target} synchronize-panes on" end
Source
# File lib/tmuxinator/window.rb, line 125 def tmux_tiled_layout_command "#{project.tmux} select-layout -t #{tmux_window_target} tiled" end
Source
# File lib/tmuxinator/window.rb, line 112 def tmux_window_command_prefix "#{project.tmux} send-keys -t #{project.name}:#{index + project.base_index}" end
Source
# File lib/tmuxinator/window.rb, line 116 def tmux_window_name_option name ? "-n #{name}" : "" end
Source
# File lib/tmuxinator/window.rb, line 102 def tmux_window_target "#{project.name}:#{index + project.base_index}" end