class Tmuxinator::Project
Attributes
yaml[R]
Public Class Methods
new(yaml)
click to toggle source
# File lib/tmuxinator/project.rb, line 9 def initialize(yaml) @yaml = yaml load_wemux_overrides if wemux? end
Public Instance Methods
base_index()
click to toggle source
# File lib/tmuxinator/project.rb, line 92 def base_index get_pane_base_index ? get_pane_base_index.to_i : get_base_index.to_i end
deprecations()
click to toggle source
# File lib/tmuxinator/project.rb, line 132 def deprecations deprecations = [] deprecations << "DEPRECATION: rbenv/rvm specific options have been replaced by the pre_tab option and will not be supported in 0.8.0." if yaml["rbenv"] || yaml["rvm"] deprecations << "DEPRECATION: The tabs option has been replaced by the windows option and will not be supported in 0.8.0." if yaml["tabs"] deprecations << "DEPRECATION: The cli_args option has been replaced by the tmux_options option and will not be supported in 0.8.0." if yaml["cli_args"] deprecations end
get_base_index()
click to toggle source
# File lib/tmuxinator/project.rb, line 144 def get_base_index tmux_config["base-index"] end
get_pane_base_index()
click to toggle source
# File lib/tmuxinator/project.rb, line 140 def get_pane_base_index tmux_config["pane-base-index"] end
name()
click to toggle source
# File lib/tmuxinator/project.rb, line 31 def name yaml["project_name"] && yaml["project_name"].shellescape || yaml["name"].shellescape end
name?()
click to toggle source
# File lib/tmuxinator/project.rb, line 108 def name? !name.nil? end
pre()
click to toggle source
# File lib/tmuxinator/project.rb, line 35 def pre pre_config = yaml["pre"] if pre_config.is_a?(Array) pre_config.join("; ") else pre_config end end
pre_window()
click to toggle source
# File lib/tmuxinator/project.rb, line 44 def pre_window if rbenv? "rbenv shell #{yaml["rbenv"]}" elsif rvm? "rvm use #{yaml["rvm"]}" elsif pre_tab? yaml["pre_tab"] else yaml["pre_window"] end end
render()
click to toggle source
# File lib/tmuxinator/project.rb, line 14 def render template = File.read(Tmuxinator::Config.template) Erubis::Eruby.new(template).result(binding) end
root()
click to toggle source
# File lib/tmuxinator/project.rb, line 27 def root yaml["project_root"] || File.expand_path(yaml["root"]) end
root?()
click to toggle source
# File lib/tmuxinator/project.rb, line 104 def root? !root.nil? end
send_keys(cmd, window_index)
click to toggle source
# File lib/tmuxinator/project.rb, line 124 def send_keys(cmd, window_index) if cmd.empty? "" else "#{tmux} send-keys -t #{window(window_index)} #{cmd.shellescape} C-m" end end
send_pane_command(cmd, window_index, pane_index)
click to toggle source
# File lib/tmuxinator/project.rb, line 116 def send_pane_command(cmd, window_index, pane_index) if cmd.empty? "" else "#{tmux} send-keys -t #{window(window_index)} #{cmd.shellescape} C-m" end end
show_tmux_options()
click to toggle source
# File lib/tmuxinator/project.rb, line 148 def show_tmux_options "#{tmux} start-server\\; show-option -g" end
socket()
click to toggle source
# File lib/tmuxinator/project.rb, line 64 def socket if socket_path " -S #{socket_path}" elsif socket_name " -L #{socket_name}" else nil end end
socket_name()
click to toggle source
# File lib/tmuxinator/project.rb, line 74 def socket_name yaml["socket_name"] end
socket_path()
click to toggle source
# File lib/tmuxinator/project.rb, line 78 def socket_path yaml["socket_path"] end
tmux()
click to toggle source
# File lib/tmuxinator/project.rb, line 56 def tmux "#{tmux_command}#{tmux_options}#{socket}" end
tmux_command()
click to toggle source
# File lib/tmuxinator/project.rb, line 60 def tmux_command yaml["tmux_command"] || "tmux" end
tmux_options()
click to toggle source
# File lib/tmuxinator/project.rb, line 82 def tmux_options if cli_args? " #{yaml["cli_args"].to_s.strip}" elsif tmux_options? " #{yaml["tmux_options"].to_s.strip}" else "" end end
tmux_options?()
click to toggle source
# File lib/tmuxinator/project.rb, line 96 def tmux_options? yaml["tmux_options"] end
window(i)
click to toggle source
# File lib/tmuxinator/project.rb, line 112 def window(i) "#{name}:#{i}" end
windows()
click to toggle source
# File lib/tmuxinator/project.rb, line 19 def windows windows_yml = yaml["tabs"] || yaml["windows"] @windows ||= windows_yml.map.with_index do |window_yml, index| Tmuxinator::Window.new(window_yml, index, self) end end
windows?()
click to toggle source
# File lib/tmuxinator/project.rb, line 100 def windows? windows.any? end
Private Instance Methods
extract_tmux_config()
click to toggle source
# File lib/tmuxinator/project.rb, line 158 def extract_tmux_config options_hash = {} options_string = %x#{show_tmux_options}` options_string.encode!("UTF-8", :invalid => :replace) options_string.split("\n").map do |entry| key, value = entry.split("\s") options_hash[key] = value options_hash end options_hash end
tmux_config()
click to toggle source
# File lib/tmuxinator/project.rb, line 154 def tmux_config @tmux_config ||= extract_tmux_config end