rosh 0.2.5 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 513050c2aee848c5c2dc576a570cb05abe6e28d3
4
- data.tar.gz: 5e330a7a4fb540e00b8e7964ea6f75a0e85d964d
3
+ metadata.gz: 5f03ab9e65cf17ee6327d425892ec00fcd19b92d
4
+ data.tar.gz: 1609dced29c0bb1b548b882358648e83fa6b71f0
5
5
  SHA512:
6
- metadata.gz: 63f9d47cbbead61ecbb127e1ac9ab4f9952aac5a1355cb920994f15b434ee9a54319858589be738589f86b109ed9ab3f523cfa629577f13a52afa61357a3c846
7
- data.tar.gz: 71e82d87c88151be0caa95055c275a3ed6a4d57e60566336e1e29907519e866baa6519f9611ac7bfbf64801deae36c133898ed3fa7d4b2c9ffafe11c2838835f
6
+ metadata.gz: c887a87750fa74cdede9dd1b70d38de6d3db34eb142a1b77f2ec33011deff74596f6c23fa7d23f8fbf8811cb1c78c4123aafa12394ebc37567cb1237f04758ca
7
+ data.tar.gz: 46ad0b56a3c47ddb99963f9bad25c71b1831e8d2d1e0bf080915e36c0a1790d23ddac4e92285e121e0802dabaa0c946cc72805aa0a2c170020ccff986789c310
data/README.md CHANGED
@@ -21,6 +21,17 @@ Or install it yourself as:
21
21
 
22
22
  rosh hostname [GNU_screen_session_name]
23
23
 
24
+ To detach the outer screen session,
25
+
26
+ ^t d
27
+
28
+ To send the command to the inner screen session,
29
+
30
+ ^a
31
+
32
+ Currently it is not configurable, but the source code is very simple
33
+ to be customizable.
34
+
24
35
  ## Contributing
25
36
 
26
37
  1. Fork it
data/bin/rosh CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  require File.join(File.dirname(__FILE__), %w[.. lib rosh])
3
3
 
4
+ Version = Rosh::VERSION
4
5
  Rosh.new(*ARGV).connect
@@ -0,0 +1,3 @@
1
+ class Rosh
2
+ VERSION = '0.3.0'
3
+ end
data/lib/rosh.rb CHANGED
@@ -1,25 +1,34 @@
1
1
  require 'uri'
2
2
  require 'resolv'
3
3
  require 'net/ssh/config'
4
+ require 'optparse'
5
+ require File.join(File.dirname(__FILE__), %w[rosh version])
4
6
 
5
7
  class Rosh
6
- def initialize(host, name = :default, *opts)
7
- @host, @name = host, name
8
- @first_try = true
8
+ def initialize(*args)
9
+ @ssh_opts = []
10
+ alive_interval = 5
11
+ @escape = '^t'
12
+ OptionParser.new.tap do |opt|
13
+ opt.on '-n' do
14
+ @ssh_opts << '-o UserKnownHostsFile=/dev/null'
15
+ @ssh_opts << '-o StrictHostKeyChecking=no'
16
+ end
17
+ opt.on('-a alive-interval'){|v| alive_interval = v.to_i}
18
+ opt.on('-e escape'){|v| @escape = v}
19
+ end.parse! args
20
+ @host, @name = *args, :default
21
+ @ssh_opts << "-o ServerAliveInterval=#{alive_interval}"
22
+ @ssh_opts << "-o ServerAliveCountMax=1"
23
+
24
+ # check ~/.ssh/config to resolve alias name
9
25
  config = Net::SSH::Config.for(@host)
10
26
  @host = config[:host_name] if config[:host_name]
11
- @opts = ["-o ServerAliveInterval=5", "-o ServerAliveCountMax=1"]
12
- opts.each do |opt|
13
- case opt
14
- when '-n'
15
- @opts << '-o UserKnownHostsFile=/dev/null'
16
- @opts << '-o StrictHostKeyChecking=no'
17
- end
18
- end
27
+ @first_try = true
19
28
  end
20
29
 
21
30
  def connect
22
- reconnect until system ["ssh", *@opts, resolv,
31
+ reconnect until system ["ssh", *@ssh_opts, resolv,
23
32
  '-t', "'screen -rx #{@name}'", '2>/dev/null']*' '
24
33
  end
25
34
 
@@ -27,7 +36,7 @@ class Rosh
27
36
  if @first_try
28
37
  if !sh('-p 0 -X echo ok', '2>&1 >/dev/null')
29
38
  print "creating new screen session #{@name}... "
30
- if sh '-c /dev/null -e "^t^t" -dm' and
39
+ if sh %{-c /dev/null -e "#{@escape*2}" -dm} and
31
40
  sh '-p 0 -X eval "stuff STY=\\040screen\\015"'
32
41
  puts "done."
33
42
  else
data/rosh.gemspec CHANGED
@@ -1,9 +1,10 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require File.join(lib, %w[rosh version])
4
5
  Gem::Specification.new do |spec|
5
6
  spec.name = "rosh"
6
- spec.version = '0.2.5'
7
+ spec.version = Rosh::VERSION
7
8
  spec.authors = ["Genki Takiuchi"]
8
9
  spec.email = ["genki@s21g.com"]
9
10
  spec.description = <<-EOD
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rosh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Takiuchi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-22 00:00:00.000000000 Z
11
+ date: 2013-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -55,6 +55,7 @@ files:
55
55
  - Rakefile
56
56
  - bin/rosh
57
57
  - lib/rosh.rb
58
+ - lib/rosh/version.rb
58
59
  - rosh.gemspec
59
60
  homepage: https://github.com/genki/rosh
60
61
  licenses: