tmux-connector 0.8.5 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -11,6 +11,7 @@ Manage multiple servers using SSH and [tmux].
11
11
  * multiple connections to individual servers possible
12
12
  * sessions can be persisted (actually recreated) after computer restarts
13
13
  - they are lost only if you delete them explicitly
14
+ * panes not associated with hosts
14
15
 
15
16
 
16
17
  ## Quick tease
@@ -178,6 +179,9 @@ name:
178
179
  regex-ignore-parts: [0, 2]
179
180
  separator: '-'
180
181
  prefix: 'dev--'
182
+ hostless:
183
+ ctrl: 1
184
+ additional: 2
181
185
  merge-groups:
182
186
  misc: ['cache', 'db', 'mongodb']
183
187
  lbs: ['haproxy', 'nginx']
@@ -254,6 +258,25 @@ Filed __'regex-ignore-parts'__ potentially removes some regex groups from name,
254
258
  __'separator'__ is used to separate left-over groups and it's possible to
255
259
  specify __'prefix'__ for the name.
256
260
 
261
+ * * *
262
+ (optional) field __'hostless'__ defines groups of panes that are not associated
263
+ with hosts. Each group is defined by the name and the number of panes.
264
+
265
+ For example,
266
+ ~~~yaml
267
+ hostless:
268
+ ctrl: 1
269
+ additional: 2
270
+ ~~~
271
+ defines 2 groups of panes without hosts. First group, 'ctrl', has only one
272
+ pane, while the second group, 'additional', has 2 panes.
273
+
274
+ Hostless panes can be used to:
275
+ * issue the tcon commands to other panes
276
+ - e.g. one control pane, in a separate window
277
+ * manage local work
278
+ * connect to a host at some point in the future
279
+
257
280
  * * *
258
281
  (optional) field __'merge-groups'__ contains groups that should be merged (for
259
282
  layout purposes) together. This can be used to group a few servers that are
@@ -264,9 +287,11 @@ lbs: ['haproxy', 'nginx']
264
287
  ~~~
265
288
  In this example two different kinds of loadbalancers are grouped together.
266
289
 
267
- Note that the servers from merge groups can later be referenced with both
290
+ Note that the servers/panes from merge groups can later be referenced with both
268
291
  original and merge-group name.
269
292
 
293
+ Hostless groups can also be merged.
294
+
270
295
  * * *
271
296
  (optional) field __'multiple-hosts'__ contains __'regexes'__ and __'counts'__
272
297
  fields. With those, some hosts can have multiple connections established, not
@@ -308,6 +333,10 @@ The layouts are applied individually to any merge group and to any normal
308
333
  a group then layout allows on a single window, next window for that group is
309
334
  added. Servers from different groups never share a window.
310
335
 
336
+ * * *
337
+ Take a look at [`spec/fixtures/configs.yml`][configs] for some configuration
338
+ possibilities (sections under 'input' fields).
339
+
311
340
 
312
341
  ## Requirements
313
342
  To be able to use the gem you should have ruby 1.9+ and tmux installed on a *nix
@@ -323,6 +352,9 @@ For a start, switching between panes/windows and attaching/detaching is enough:
323
352
  * navigate windows (next/previous): `<prefix>n` & `<prefix>p`
324
353
  * navigate panes: `<prefix><arrow>`
325
354
 
355
+ Also useful:
356
+ * toggle pane zoom: `<prefix>z`
357
+
326
358
  (prefix is by default `C-b`)
327
359
 
328
360
 
@@ -392,7 +424,10 @@ ivan@<< username >>.com
392
424
 
393
425
  I'd be happy to hear from you.
394
426
 
427
+ Also, visit my [homepage].
428
+
395
429
 
430
+ [configs]: /spec/fixtures/configs.yml
396
431
  [docopt]: https://github.com/docopt/docopt
397
432
  [tmux]: http://en.wikipedia.org/wiki/Tmux
398
433
  [CLI]: http://en.wikipedia.org/wiki/Command-line_interface
@@ -400,3 +435,4 @@ I'd be happy to hear from you.
400
435
  [dotfiles]: https://github.com/ikusalic/dotfiles
401
436
  [YAML]: http://en.wikipedia.org/wiki/YAML
402
437
  [rubulator]: http://rubular.com/
438
+ [homepage]: http://www.ikusalic.com/
@@ -42,6 +42,11 @@ module TmuxConnector
42
42
  acc[e.group_id] << e
43
43
  acc
44
44
  end
45
+
46
+ if (hostless = config['hostless'])
47
+ @groups.merge! Hash[hostless.map { |name, count| [ name, [FakeHost.new(name, count)] ] }]
48
+ end
49
+
45
50
  sort_groups!
46
51
  end
47
52
 
@@ -52,11 +57,11 @@ module TmuxConnector
52
57
  elements.each { |e| @merge_rules[e] = name }
53
58
  end
54
59
  end
55
- @groups.keys.each { |e| @merge_rules[e] ||= e }
60
+ groups.keys.each { |e| @merge_rules[e] ||= e }
56
61
  end
57
62
 
58
63
  def sort_groups!()
59
- @groups.each do |k, v|
64
+ groups.each do |k, v|
60
65
  numbers_only = v.all? { |e| e.sort_value =~ /^[-+]?[0-9]+$/ }
61
66
  if numbers_only
62
67
  v.sort! { |a, b| a.sort_value.to_i <=> b.sort_value.to_i }
@@ -6,7 +6,7 @@ module TmuxConnector
6
6
 
7
7
  def self.get_config(config_file)
8
8
  config = read_config config_file
9
- process_config! config
9
+ process_config!(config) rescue raise 'configuration file parsing failed'
10
10
  return config
11
11
  end
12
12
 
@@ -21,8 +21,7 @@ module TmuxConnector
21
21
  def self.process_config!(config)
22
22
  config['regex'] = Regexp.new config['regex']
23
23
  config['reject-regex'] = Regexp.new(config['reject-regex']) if config['reject-regex']
24
- if config['name']
25
- c = config['name']
24
+ if (c = config['name'])
26
25
  c['regex-ignore-parts'] ||= []
27
26
  c['separator'] ||= '-'
28
27
  c['prefix'] ||= ''
@@ -33,7 +33,7 @@ module TmuxConnector
33
33
  return config['name']['prefix'] + parts.join(config['name']['separator'])
34
34
  end
35
35
 
36
- return @ssh_name
36
+ return ssh_name
37
37
  end
38
38
 
39
39
  def get_count(config)
@@ -47,4 +47,23 @@ module TmuxConnector
47
47
  return 1
48
48
  end
49
49
  end
50
+
51
+ class FakeHost
52
+ attr_reader :count
53
+ attr_reader :display_name
54
+ attr_reader :group_id
55
+ attr_reader :sort_value
56
+ attr_reader :ssh_name
57
+
58
+ def initialize(name, count)
59
+ @display_name = @group_id = @ssh_name = name
60
+ @count = count
61
+
62
+ @sort_value = nil
63
+ end
64
+
65
+ def to_s()
66
+ return "<fake-host::#{ display_name }-#{ count }>"
67
+ end
68
+ end
50
69
  end
@@ -44,6 +44,7 @@ module TmuxConnector
44
44
  else
45
45
  matches = server_regex.nil? && group_regex.nil?
46
46
  matches ||= !server_regex.nil? && pane.host.ssh_name.match(server_regex)
47
+ matches ||= !group_regex.nil? && pane.host.group_id.match(group_regex)
47
48
  matches ||= !group_regex.nil? && session.merge_rules[pane.host.group_id].match(group_regex)
48
49
  end
49
50
 
@@ -114,6 +115,8 @@ HERE
114
115
  ssh_config_path = File.expand_path session.args['--ssh-config']
115
116
 
116
117
  each_pane do |window_index, pane_index, pane|
118
+ next unless pane.host.instance_of? TmuxConnector::Host
119
+
117
120
  ssh_command = "ssh -F #{ ssh_config_path } #{ pane.host.ssh_name }"
118
121
  commands << "tmux send-keys -t #{ name }:#{ window_index }.#{ pane_index } '#{ ssh_command }' C-m"
119
122
  end
@@ -1,3 +1,3 @@
1
1
  module TmuxConnector
2
- VERSION = "0.8.5"
2
+ VERSION = "0.8.6"
3
3
  end
data/spec/config_spec.rb CHANGED
@@ -50,5 +50,10 @@ describe "Configuration file" do
50
50
  describe "multiple hosts" do
51
51
  it_should_behave_like "config test", 'multiple-hosts'
52
52
  end
53
+
54
+ describe "panes without hosts" do
55
+ it_should_behave_like "config test", 'hostless'
56
+ it_should_behave_like "config test", 'hostless-merge'
57
+ end
53
58
  end
54
59
  end
@@ -129,3 +129,29 @@ multiple-hosts:
129
129
  - !ruby-regexp '(loadbalancer)-'
130
130
  - !ruby-regexp '(database)-'
131
131
  counts: [2, 3]
132
+
133
+ hostless:
134
+ input:
135
+ <<: *input-min
136
+ hostless:
137
+ ctrl: 2
138
+ smt: 4
139
+ expected:
140
+ <<: *expected-min
141
+ hostless:
142
+ ctrl: 2
143
+ smt: 4
144
+
145
+ hostless-merge:
146
+ input:
147
+ <<: *input-min
148
+ hostless:
149
+ ctrl: 2
150
+ merge-groups:
151
+ misc: ['ctrl', 'repo']
152
+ expected:
153
+ <<: *expected-min
154
+ hostless:
155
+ ctrl: 2
156
+ merge-groups:
157
+ misc: ['ctrl', 'repo']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tmux-connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.5
4
+ version: 0.8.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-08 00:00:00.000000000 Z
12
+ date: 2013-06-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: docopt