class FortMux::Status
Constants
- NO_SERVER_RE
- PANE_RE
- SESSION_RE
- WINDOW_RE
Attributes
sessions[R]
Public Class Methods
new()
click to toggle source
# File lib/FortMux.rb, line 107 def initialize @sessions = [] # server not found: No such file or directory # on stderr, not stdout listSessions = `tmux list-sessions` if listSessions.length == 0 return end listSessions.split("\n").each do |line| if line =~ SESSION_RE sessions << {:session => $~[:session], :x => $~[:x], :y => $~[:y], :windows => []} end end @sessions.each do |s| listWindows = `tmux list-windows -t #{s[:session]}` listWindows.split("\n").each do |line| if line =~ WINDOW_RE s[:windows] << {:window => $~[:window], :index => $~[:index], :x => $~[:x], :y => $~[:y], :panes => []} end end s[:windows].each do |w| listPanes = `tmux list-panes -t #{s[:session]}:#{s[:window]}` listPanes.split("\n").each do |line| if line =~ PANE_RE w[:panes] << {:index => $~[:index], :x => $~[:x], :y => $~[:y]} end end end end end
Public Instance Methods
find(sessionName,windowName=nil)
click to toggle source
# File lib/FortMux.rb, line 91 def find(sessionName,windowName=nil) session = @sessions.detect { |s| s[:session].downcase == sessionName.downcase } if session && windowName session[:windows].detect { |w| w[:window].downcase == windowName.downcase } else session end end
window_count(sessionName)
click to toggle source
# File lib/FortMux.rb, line 99 def window_count(sessionName) session = find sessionName if session && session.has_key?(:windows) session[:windows].length else 0 end end