Sha256: 0a1c6d28d755b2d5a2b45d4c37f7ead1fe67c754085d6a933149267e4ef79d9b
Contents?: true
Size: 1.46 KB
Versions: 1
Compression:
Stored size: 1.46 KB
Contents
require 'fileutils' module Pair class Session class Tmux TMP_PATH = "/tmp" attr_accessor :session private :session= def initialize(session) self.session = session create_socket_directory end def app_path self.class.to_s.split('::').first.downcase end def unique @unique ||= srand.to_s[0,5] end def start args = %W[-S #{socket_path} new-session -d] system "tmux", *args at_exit { stop } end def stop `lsof -t #{socket_path}/ | xargs kill -9` FileUtils.rm_f(socket_path) self.session.cleanup_authorized_keys if self.session.respond_to?(:cleanup_authorized_keys) end def window(command) args = %W[ -S #{socket_path} new-window -t #{session.name}:0 -n 'Pairing' 'ssh pair@bastion.pairmill.com -A' ] system "tmux", *args end def attach(read_only = false) args = %W[-S #{socket_path} attach] args += " -r" if read_only system "tmux", *args end private def create_socket_directory FileUtils.mkdir_p(socket_directory, :mode => 0700) end def socket_directory File.join TMP_PATH, app_path end def socket_path File.join socket_directory, socket_name end def socket_name "tmux-#{session.name}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pair-0.0.1 | lib/pair/session/tmux.rb |