Sha256: d76786ea1887244d1d18b162ec21e7e90429dc5d7201f94eb24f76fefade5e7c
Contents?: true
Size: 1.82 KB
Versions: 2
Compression:
Stored size: 1.82 KB
Contents
module Teamocil class Layout # This class represents a split within a tmux window class Split attr_reader :width, :height, :cmd, :index, :target # Initialize a new tmux split # # @param session [Session] the window where the split is initialized # @param index [Fixnnum] the split index # @param attrs [Hash] the split data from the layout file def initialize(window, index, attrs={}) # {{{ @height = attrs["height"] @width = attrs["width"] @cmd = attrs["cmd"] @target = attrs["target"] @window = window @index = index end # }}} # Generate commands to send to tmux # # @return [Array] def generate_commands # {{{ commands = [] # Is it a vertical or horizontal split? init_command = "" unless @index == 0 if !@width.nil? init_command = "tmux split-window -h -p #{@width}" elsif !@height.nil? init_command = "tmux split-window -p #{@height}" else init_command = "tmux split-window" end init_command << " -t #{@target}" unless @target.nil? commands << init_command end # Wrap all commands around filters @cmd = [@window.filters["before"]] + [@cmd] + [@window.filters["after"]] # If a `root` key exist, start each split in this directory @cmd.unshift "cd \"#{@window.root}\"" unless @window.root.nil? # Set the TEAMOCIL environment variable @cmd.unshift "export TEAMOCIL=1" # Execute each split command @cmd.flatten.compact.each do |command| commands << "tmux send-keys -t #{@index} \"#{command}\"" commands << "tmux send-keys -t #{@index} Enter" end commands end # }}} end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
teamocil-0.3.3 | lib/teamocil/layout/split.rb |
teamocil-0.3.2 | lib/teamocil/layout/split.rb |