Class: TmRb::Multiplexer
Instance Method Summary collapse
-
#active_window(num) ⇒ Object
Set the active window in that session.
-
#initialize ⇒ Multiplexer
constructor
A new instance of Multiplexer.
-
#new_session(options = {}) ⇒ Object
Creates a new tmux session.
-
#new_window(options = {}) ⇒ Object
Creates a new tmux window.
-
#start(process_info = {}) ⇒ Object
Start tmux.
Constructor Details
#initialize ⇒ Multiplexer
Returns a new instance of Multiplexer.
10 11 12 |
# File 'lib/tmrb.rb', line 10 def initialize @sessions = [] end |
Instance Method Details
#active_window(num) ⇒ Object
Set the active window in that session
67 68 69 70 71 |
# File 'lib/tmrb.rb', line 67 def active_window(num) # the active window will always be set for the last defined session session = get_last_session session.active_window(num) end |
#new_session(options = {}) ⇒ Object
Creates a new tmux session
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/tmrb.rb', line 21 def new_session(={}) = { :session_name => 'default', :window_name => 'tab', :command => 'zsh' }.update if @sessions.find { |s| s.session_name == [:session_name] } raise DuplicateSessionIdentifier , "Please do not reuse the session identifier. You used \"#{options[:session_name]}\" at least twice." end session = Session.new([:session_name], [:window_name], [:command]) @sessions << session session end |
#new_window(options = {}) ⇒ Object
Creates a new tmux window
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/tmrb.rb', line 43 def new_window(={}) = { :name => 'tab', :command => 'zsh' }.update # windows will be attached to the last session defined session = get_last_session #if no sessions have been created, create a new one if session == nil say "Warning: No valid session found. Create a default one" session = new_session end #windows belong to a session session.add_window Window.new( [:name] , [:command] ) end |
#start(process_info = {}) ⇒ Object
Start tmux
97 98 99 100 101 102 |
# File 'lib/tmrb.rb', line 97 def start(process_info={}) process_info[:cmd] = 'tmux' process_info[:status] = system(%Q{#{process_info[:cmd]} #{build_multiplexer_command_string} attach}) end |