rosh 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -2
  3. data/lib/rosh/version.rb +1 -1
  4. data/lib/rosh.rb +43 -0
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f64f95564122ea852fb93ffc481aac5a7977aca6c6858f716e3495f17ae07fc5
4
- data.tar.gz: c364da8eeea9ec17bf927ecca79eda010393043c5580d4259929f7eded253a8d
3
+ metadata.gz: c281394b7c56d31763a538fe527e83e811fbd96c9cb777e203f1e6805309e8f0
4
+ data.tar.gz: 79b3f328162456af2d3b5d582ef3773244c05764a1b25b56921361d92033deee
5
5
  SHA512:
6
- metadata.gz: 5eb516a7aecaa2d2baed09ca47941da6b6ba25530ba3b8b7eee3c04db2d5633164c038c913b1b0d326be9e2f8a91f9360acdaaa08f4d75a86b2267f170128f83
7
- data.tar.gz: d565efa2e2a73328570f810270018935056c21328b75130e9f636b8ad1715bf1a35ee10a966493814540cf3aaacaffe2b6532ab6a39c4029aa7ebde9c2c8abb6
6
+ metadata.gz: 2fdf8acb2e2973c428320999966fc7c071e67cb35afea53570fb1781ca718facbefecf7ee0e15d8c90aca387a8a828a6ce3ed97648c8bdeb3f4c34505d724ecf
7
+ data.tar.gz: 75389ed8edf6e5a84512d52071ceeba6f618725d94841887afd3fb08a4fe285d593cdebf32ded16359f9460cd3731de15991af9eb0129d19ef121a45f6a5bbfb
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Rosh
2
2
 
3
3
  Rosh is roaming shell.
4
- It can automatically reconnect to the host with the remote GNU screen session.
4
+ It can automatically reconnect to the host with the remote tmux or GNU screen session.
5
5
 
6
6
  ## Installation
7
7
 
@@ -19,13 +19,16 @@ Or install it yourself as:
19
19
 
20
20
  ## Usage
21
21
 
22
- rosh [options] hostname [GNU_screen_session_name]
22
+ rosh [options] hostname [session_name]
23
23
 
24
24
  -a alive-interval Set ssh option ServerAliveInterval. Default: 5
25
25
  -e escape Set the escape charactor of the outer screen session.
26
26
  Default: "^t"
27
27
  -I interval Reconnection interval.
28
+ -S Use GNU screen instead of tmux
28
29
 
30
+ If ~/.ssh/config contains LocalForward or RemoteForward for the host, the same
31
+ forwarding options are passed to `ssh` automatically.
29
32
  To detach the outer screen session,
30
33
 
31
34
  ^t d
data/lib/rosh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Rosh
2
- VERSION = '0.9.0'
2
+ VERSION = '0.9.1'
3
3
  end
data/lib/rosh.rb CHANGED
@@ -24,10 +24,17 @@ class Rosh
24
24
  @ssh_opts << "-o ServerAliveCountMax=1"
25
25
 
26
26
  # check ~/.ssh/config to resolve alias name
27
+ alias_name = @host
27
28
  config = Net::SSH::Config.for(@host)
28
29
  if @verbose
29
30
  puts "ssh-config: #{config}"
30
31
  end
32
+ local_forwards(alias_name).each do |f|
33
+ @ssh_opts << "-L #{f}"
34
+ end
35
+ remote_forwards(alias_name).each do |f|
36
+ @ssh_opts << "-R #{f}"
37
+ end
31
38
  @host = config[:host_name] if config[:host_name]
32
39
  @ssh_opts << "-l #{config[:user]}" if config[:user]
33
40
  @ssh_opts << "-p #{config[:port]}" if config[:port]
@@ -123,6 +130,42 @@ private
123
130
  system cmd
124
131
  end
125
132
 
133
+ def local_forwards(host)
134
+ file = File.expand_path("~/.ssh/config")
135
+ return [] unless File.readable?(file)
136
+ forwards = []
137
+ current = false
138
+ File.foreach(file) do |line|
139
+ line = line.sub(/#.*/, '').strip
140
+ next if line.empty?
141
+ if line =~ /^Host\s+(.*)/i
142
+ patterns = $1.split(/\s+/)
143
+ current = patterns.any? { |p| host =~ Net::SSH::Config.send(:pattern2regex, p) }
144
+ elsif current && line =~ /^LocalForward\s+(.*)/i
145
+ forwards << $1.strip.gsub(/\s+/, ':')
146
+ end
147
+ end
148
+ forwards
149
+ end
150
+
151
+ def remote_forwards(host)
152
+ file = File.expand_path("~/.ssh/config")
153
+ return [] unless File.readable?(file)
154
+ forwards = []
155
+ current = false
156
+ File.foreach(file) do |line|
157
+ line = line.sub(/#.*/, '').strip
158
+ next if line.empty?
159
+ if line =~ /^Host\s+(.*)/i
160
+ patterns = $1.split(/\s+/)
161
+ current = patterns.any? { |p| host =~ Net::SSH::Config.send(:pattern2regex, p) }
162
+ elsif current && line =~ /^RemoteForward\s+(.*)/i
163
+ forwards << $1.strip.gsub(/\s+/, ':')
164
+ end
165
+ end
166
+ forwards
167
+ end
168
+
126
169
  def resolv
127
170
  uri = URI("//#{@host}")
128
171
  uri.host = Resolv::DNS.new.getaddress(uri.host).to_s
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.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Takiuchi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-27 00:00:00.000000000 Z
11
+ date: 2025-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: net-ssh