Class: Appear::Tmux

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

Overview

The Tmux service is in charge of interacting with ‘tmux` processes. It is used by the Tmux revealer, but could also be used as the building block for other tmux-related scripts.

see the man page for tmux if you are curious about what clients, windows, panes, and sessions are in Tmux world.

Instance Method Summary collapse

Methods inherited from BaseService

delegate, #initialize, require_service, required_services

Constructor Details

This class inherits a constructor from Appear::BaseService

Instance Method Details

#clientsObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/appear/tmux.rb', line 14

def clients
  ipc([
    'list-clients',
    '-F',
    format_string(
      :tty => :client_tty,
      :term => :client_termname,
      :session => :client_session
  ),
  ])
end

#panesObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/appear/tmux.rb', line 26

def panes
  panes = ipc([
    'list-panes',
    '-a',
    '-F',
    format_string(
      :pid => :pane_pid,
      :session => :session_name,
      :window => :window_index,
      :pane => :pane_index,
      :command_name => :pane_current_command,
      :active => :pane_active)
  ])

  panes.each do |pane|
    pane.window = pane.window.to_i
    pane.pid = pane.pid.to_i
    pane.active = pane.active.to_i != 0
  end

  panes
end

#reveal_pane(pane) ⇒ Object



49
50
51
52
# File 'lib/appear/tmux.rb', line 49

def reveal_pane(pane)
  ipc(['select-pane', '-t', "#{pane.session}:#{pane.window}.#{pane.pane}"])
  ipc(['select-window', '-t', "#{pane.session}:#{pane.window}"])
end