Class: Pair::Session::Tmux

Inherits:
Object
  • Object
show all
Defined in:
lib/pair/session/tmux.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session_name) ⇒ Tmux

Returns a new instance of Tmux.



10
11
12
# File 'lib/pair/session/tmux.rb', line 10

def initialize(session_name)
  self.session_name = session_name
end

Instance Attribute Details

#session_nameObject

Returns the value of attribute session_name.



7
8
9
# File 'lib/pair/session/tmux.rb', line 7

def session_name
  @session_name
end

Instance Method Details

#attach(read_only = false) ⇒ Object



19
20
21
# File 'lib/pair/session/tmux.rb', line 19

def attach(read_only = false)
  system(*attach_command(read_only))
end

#attach_command(read_only = false) ⇒ Object



28
29
30
31
32
# File 'lib/pair/session/tmux.rb', line 28

def attach_command(read_only = false)
  args = %W[#{tmux} -S #{socket_path} attach]
  args << " -r" if read_only
  args
end

#startObject



14
15
16
17
# File 'lib/pair/session/tmux.rb', line 14

def start
  args = %W[-S #{socket_path} new-session -d]
  system tmux, *args
end

#stopObject



23
24
25
26
# File 'lib/pair/session/tmux.rb', line 23

def stop
  `lsof -t #{socket_path}/ 2>/dev/null | xargs kill -9`
  FileUtils.rm_f(socket_path)
end