Class: ScTmux::Sc
- Inherits:
-
Object
- Object
- ScTmux::Sc
- Includes:
- Methadone::CLILogging, Methadone::Main, Methadone::SH
- Defined in:
- lib/sc_tmux.rb
Class Method Summary collapse
Class Method Details
.attach ⇒ Object
73 74 75 76 |
# File 'lib/sc_tmux.rb', line 73 def self.attach grab sh("tmux -L #{[:name]} attach") end |
.create ⇒ Object
68 69 70 71 |
# File 'lib/sc_tmux.rb', line 68 def self.create grab sh("tmux -L #{[:name]}") end |
.fix ⇒ Object
58 59 60 |
# File 'lib/sc_tmux.rb', line 58 def self.fix puts File.read([:agent_file]) end |
.grab ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/sc_tmux.rb', line 48 def self.grab File.unlink([:agent_file]) if File.exist?([:agent_file]) f = File.new([:agent_file], "w") %w(SSH_CLIENT SSH_TTY SSH_AUTH_SOCK SSH_CONNECTION).each do |var| f.write("#{var}=\"#{ENV[var]}\"\n") end f.close end |
.setup ⇒ Object
43 44 45 46 |
# File 'lib/sc_tmux.rb', line 43 def self.setup puts "Add the following alias to wherever you keep aliases:" puts "alias fixssh='eval $(sc -f)'" end |
.ssh(host) ⇒ Object
62 63 64 65 66 |
# File 'lib/sc_tmux.rb', line 62 def self.ssh(host) which_ssh = `which ssh`.chomp display_host = /(.+@)?(([0-9]+\.){3}[0-9]+|([^.]+))/.match(host)[2] sh("tmux new-window -n #{display_host} \"echo 'Using: #{which_ssh}' ; . #{[:agent_file]} ; ssh -A #{host}\"") end |