Class: Appear::Tmux::Session

Inherits:
TmuxValue show all
Defined in:
lib/appear/tmux.rb

Overview

A tmux session. Has many windows.

Instance Method Summary collapse

Methods inherited from TmuxValue

format_string, parse, property, #tmux

Methods inherited from Util::ValueClass

#initialize, properties, property

Constructor Details

This class inherits a constructor from Appear::Util::ValueClass

Instance Method Details

#attachedFixnum

Returns number of clients attached to this session.

Returns:

  • (Fixnum)

    number of clients attached to this session



133
# File 'lib/appear/tmux.rb', line 133

property :attached, :tmux => :session_attached, :parse => :to_i

#clientsArray<Client>

Returns all clients attached to this session.

Returns:

  • (Array<Client>)

    all clients attached to this session



155
156
157
# File 'lib/appear/tmux.rb', line 155

def clients
  tmux.clients.select { |c| c.session == session }
end

#heightFixnum

Returns height, in text rows.

Returns:

  • (Fixnum)

    height, in text rows



139
# File 'lib/appear/tmux.rb', line 139

property :height, :tmux => :session_height, :parse => :to_i

#idString

Returns tmux id of this session.

Returns:

  • (String)

    tmux id of this session



130
# File 'lib/appear/tmux.rb', line 130

property :id, :tmux => :session_id

#new_window(opts = {}) ⇒ Object

Create a new window in this session. By default, the window will be created at the end of the session.

Parameters:

  • opts (Hash) (defaults to: {})


163
164
165
166
# File 'lib/appear/tmux.rb', line 163

def new_window(opts = {})
  win = windows.last.window || -1
  tmux.new_window(opts.merge(:t => "#{target}:#{win + 1}"))
end

#sessionString

Returns session name.

Returns:

  • (String)

    session name



127
# File 'lib/appear/tmux.rb', line 127

property :session, tmux: :session_name

#targetString

String suitable for use as the “target” specifier for a Tmux command

Returns:

  • (String)


144
145
146
147
# File 'lib/appear/tmux.rb', line 144

def target
  # session
  id
end

#widthFixnum

Returns width, in text columns.

Returns:

  • (Fixnum)

    width, in text columns



136
# File 'lib/appear/tmux.rb', line 136

property :width, :tmux => :session_width, :parse => :to_i

#windowsArray<Window>

Returns the windows in this session.

Returns:

  • (Array<Window>)

    the windows in this session



150
151
152
# File 'lib/appear/tmux.rb', line 150

def windows
  tmux.windows.select { |w| w.session == session }
end