Sha256: 61e6e84374e3fe3a8d193cf5bd0deb763d330a4bb3826b17107e9e7cd1cce078
Contents?: true
Size: 1.26 KB
Versions: 3
Compression:
Stored size: 1.26 KB
Contents
module Teamocil class Layout attr_accessor :config, :name def initialize(name, file) # {{{ @layout = YAML.load_file(file) @name = name end # }}} def to_tmux # {{{ commands = generate_commands execute_commands(commands) end # }}} def generate_commands # {{{ output = [] @layout["windows"].each do |window| output << "tmux new-window -n #{window["name"]}" window["splits"].each_with_index do |split, index| unless index == 0 if split.include?("width") output << "tmux split-window -h -p #{split["width"]}" else if split.include?("height") output << "tmux split-window -p #{split["height"]}" else output << "tmux split-window" end end end split["cmd"] = [split["cmd"]] unless split["cmd"].is_a? Array split["cmd"].each do |command| output << "tmux send-keys -t #{index} \"#{command}\"" output << "tmux send-keys -t #{index} Enter" end end end output << "tmux select-pane -t 0" end # }}} def execute_commands(commands) # {{{ `#{commands.join("; ")}` end # }}} end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
teamocil-0.1.2 | lib/teamocil/layout.rb |
teamocil-0.1.1 | lib/teamocil/layout.rb |
teamocil-0.1 | lib/teamocil/layout.rb |