Class: Pair::Session::Tmux
- Inherits:
-
Object
- Object
- Pair::Session::Tmux
- Defined in:
- lib/pair/session/tmux.rb
Constant Summary collapse
- TMP_PATH =
"/tmp"
Instance Attribute Summary collapse
-
#session ⇒ Object
readonly
Returns the value of attribute session.
Instance Method Summary collapse
- #app_path ⇒ Object
- #attach(read_only = false) ⇒ Object
-
#initialize(session) ⇒ Tmux
constructor
A new instance of Tmux.
- #start ⇒ Object
- #stop ⇒ Object
- #unique ⇒ Object
- #window(command) ⇒ Object
Constructor Details
#initialize(session) ⇒ Tmux
Returns a new instance of Tmux.
11 12 13 14 |
# File 'lib/pair/session/tmux.rb', line 11 def initialize(session) self.session = session create_socket_directory end |
Instance Attribute Details
#session ⇒ Object
Returns the value of attribute session.
8 9 10 |
# File 'lib/pair/session/tmux.rb', line 8 def session @session end |
Instance Method Details
#app_path ⇒ Object
16 17 18 |
# File 'lib/pair/session/tmux.rb', line 16 def app_path self.class.to_s.split('::').first.downcase end |
#attach(read_only = false) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/pair/session/tmux.rb', line 49 def attach(read_only = false) args = %W[-S #{socket_path} attach] args += " -r" if read_only system "tmux", *args end |
#start ⇒ Object
24 25 26 27 28 29 |
# File 'lib/pair/session/tmux.rb', line 24 def start args = %W[-S #{socket_path} new-session -d] system "tmux", *args at_exit { stop } end |
#stop ⇒ Object
31 32 33 34 35 |
# File 'lib/pair/session/tmux.rb', line 31 def stop `lsof -t #{socket_path}/ | xargs kill -9` FileUtils.rm_f(socket_path) self.session. if self.session.respond_to?(:cleanup_authorized_keys) end |
#unique ⇒ Object
20 21 22 |
# File 'lib/pair/session/tmux.rb', line 20 def unique @unique ||= srand.to_s[0,5] end |
#window(command) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/pair/session/tmux.rb', line 37 def window(command) args = %W[ -S #{socket_path} new-window -t #{session.name}:0 -n 'Pairing' 'ssh [email protected] -A' ] system "tmux", *args end |