tmuxinator 3.1.0 → 3.1.1

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
  SHA256:
3
- metadata.gz: 15e0d5df60a8ef8a65cae1958913c16aed4cd5d563573f7589283f210d40139b
4
- data.tar.gz: af34c5d6d4f609255b55f7dd662c9193cec07235abb9eb1695722c01e494fcdf
3
+ metadata.gz: 619a96d44867a826eedbf13ac8330ef27cb44dbd74810cc4229d83e5ea35c9e0
4
+ data.tar.gz: 4de7af75ee47dd790ba37e5715e52fd7e2a3097b3ab7755d21d7c53c53e99407
5
5
  SHA512:
6
- metadata.gz: 177be80a0ae306774cb96ec56d1943cc6e3b5459a9398911be92cf1d7310f71f8191ce8c3ef6745a855574353de20b34eb551221f60f5c9ed53c28e2e94ca10c
7
- data.tar.gz: 18b6fbac38dbee55ccbeeb5318b216ca7cb52c1119ac5517369f4b938ad574b5084a73a66a85b6aadc53fff3435705b3412c2c56054fdfe0cd8ccade6494733e
6
+ metadata.gz: 67d77b09a4632cdace3306ae7d76a13e605debbbc8fb52fc5217ded9ff6a90c6c36e1f66788c1d652feab82f2b03c4c1150bf67a3df5143b08db6a8139eaf3bd
7
+ data.tar.gz: 634a7911404b858c551b1cb00fe1eff80e377818bd128b9d210bf2359113246698427e0662e307a59c842d8e41d1d145bcee19ff5a90a0c35f06e5217a66a907
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env bash
2
-
3
1
  _tmuxinator() {
4
2
  COMPREPLY=()
5
3
  local word
@@ -32,7 +32,7 @@ root: ~/
32
32
  # Pass command line options to tmux. Useful for specifying a different tmux.conf.
33
33
  # tmux_options: -f ~/.tmux.mac.conf
34
34
 
35
- # Change the command to call tmux. This can be used by derivatives/wrappers like byobu.
35
+ # Change the command to call tmux. This can be used by derivatives/wrappers like byobu.
36
36
  # tmux_command: byobu
37
37
 
38
38
  # Specifies (by name or index) which window will be selected on project startup. If not set, the first window is used.
@@ -15,7 +15,7 @@ cd <%= root || "." %>
15
15
 
16
16
  # Run pre command.
17
17
  <%= pre %>
18
-
18
+
19
19
  # Run on_project_first_start command.
20
20
  <%= hook_on_project_first_start %>
21
21
 
@@ -53,6 +53,9 @@ cd <%= root || "." %>
53
53
  <% end %>
54
54
  <% else %>
55
55
  <% window.panes.each do |pane| %>
56
+ <% unless Tmuxinator::Config.version < 2.6 %>
57
+ <%= pane.tmux_set_title %>
58
+ <% end %>
56
59
  <% if pane.project.pre_window %>
57
60
  <%= pane.tmux_pre_window_command %>
58
61
  <% end %>
@@ -94,6 +97,6 @@ cd <%= root || "." %>
94
97
  <%- end -%>
95
98
 
96
99
  <%= post %>
97
-
100
+
98
101
  # Run on_project_exit command.
99
102
  <%= hook_on_project_exit %>
@@ -264,14 +264,23 @@ module Tmuxinator
264
264
  render_project(project)
265
265
  end
266
266
 
267
- desc "stop [PROJECT]", COMMANDS[:stop]
267
+ desc "stop [PROJECT] [ARGS]", COMMANDS[:stop]
268
268
  map "st" => :stop
269
+ method_option "project-config", aliases: "-p",
270
+ desc: "Path to project config file"
269
271
  method_option "suppress-tmux-version-warning",
270
272
  desc: "Don't show a warning for unsupported tmux versions"
271
273
 
272
- def stop(name)
274
+ def stop(name = nil)
275
+ # project-config takes precedence over a named project in the case that
276
+ # both are provided.
277
+ if options["project-config"]
278
+ name = nil
279
+ end
280
+
273
281
  params = {
274
- name: name
282
+ name: name,
283
+ project_config: options["project-config"]
275
284
  }
276
285
  show_version_warning if version_warning?(
277
286
  options["suppress-tmux-version-warning"]
@@ -12,7 +12,7 @@ module Tmuxinator
12
12
  return environment if environment?
13
13
  return xdg if xdg?
14
14
  return home if home?
15
- # No project directory specified or existant, default to XDG:
15
+ # No project directory specified or existent, default to XDG:
16
16
  FileUtils::mkdir_p(xdg)
17
17
  xdg
18
18
  end
@@ -127,7 +127,7 @@ module Tmuxinator
127
127
  end.flatten.sort
128
128
  end
129
129
 
130
- # Existant directories which may contain project files
130
+ # Existent directories which may contain project files
131
131
  # Listed in search order
132
132
  # Used by `implode` and `list` commands
133
133
  def directories
@@ -1,12 +1,13 @@
1
1
  module Tmuxinator
2
2
  class Pane
3
- attr_reader :commands, :project, :index, :tab
3
+ attr_reader :commands, :project, :index, :tab, :title
4
4
 
5
- def initialize(index, project, tab, *commands)
5
+ def initialize(index, project, tab, *commands, title: nil)
6
6
  @commands = commands
7
7
  @index = index
8
8
  @project = project
9
9
  @tab = tab
10
+ @title = title
10
11
  end
11
12
 
12
13
  def tmux_window_and_pane_target
@@ -29,6 +30,12 @@ module Tmuxinator
29
30
  end
30
31
  end
31
32
 
33
+ def tmux_set_title
34
+ unless title.nil?
35
+ _set_title(title)
36
+ end
37
+ end
38
+
32
39
  def name
33
40
  project.name
34
41
  end
@@ -61,5 +68,10 @@ module Tmuxinator
61
68
  def _send_keys(t, e)
62
69
  "#{project.tmux} send-keys -t #{t} #{e} C-m"
63
70
  end
71
+
72
+ def _set_title(title)
73
+ target = tmux_window_and_pane_target
74
+ "#{project.tmux} select-pane -t #{target} -T #{title}"
75
+ end
64
76
  end
65
77
  end
@@ -1,6 +1,7 @@
1
1
  module Tmuxinator
2
2
  module TmuxVersion
3
3
  SUPPORTED_TMUX_VERSIONS = [
4
+ "3.4",
4
5
  "3.3a",
5
6
  3.3,
6
7
  "3.2a",
@@ -1,3 +1,3 @@
1
1
  module Tmuxinator
2
- VERSION = "3.1.0".freeze
2
+ VERSION = "3.1.1".freeze
3
3
  end
@@ -50,16 +50,16 @@ module Tmuxinator
50
50
  return if panes_yml.nil?
51
51
 
52
52
  Array(panes_yml).map.with_index do |pane_yml, index|
53
- commands = case pane_yml
54
- when Hash
55
- pane_yml.values.first
56
- when Array
57
- pane_yml
58
- else
59
- pane_yml
60
- end
61
-
62
- Tmuxinator::Pane.new(index, project, self, *commands)
53
+ commands, title = case pane_yml
54
+ when Hash
55
+ [pane_yml.values.first, pane_yml.keys.first]
56
+ when Array
57
+ [pane_yml, nil]
58
+ else
59
+ [pane_yml, nil]
60
+ end
61
+
62
+ Tmuxinator::Pane.new(index, project, self, *commands, title: title)
63
63
  end.flatten
64
64
  end
65
65
 
@@ -303,14 +303,24 @@ describe Tmuxinator::Cli do
303
303
 
304
304
  describe "#stop" do
305
305
  before do
306
- ARGV.replace(["stop", "foo"])
307
306
  allow(Tmuxinator::Config).to receive_messages(validate: project)
308
307
  allow(Tmuxinator::Config).to receive_messages(version: 1.9)
309
308
  allow(Kernel).to receive(:exec)
310
309
  end
311
310
 
312
311
  context "with project name" do
313
- it "stop the project" do
312
+ it "stops the project" do
313
+ ARGV.replace(["stop", "foo"])
314
+ expect(Kernel).to receive(:exec)
315
+ out, err = capture_io { cli.start }
316
+ expect(err).to eq ""
317
+ expect(out).to eq ""
318
+ end
319
+ end
320
+
321
+ context "without project name" do
322
+ it "stops the project using .tmuxinator.yml" do
323
+ ARGV.replace(["stop"])
314
324
  expect(Kernel).to receive(:exec)
315
325
  out, err = capture_io { cli.start }
316
326
  expect(err).to eq ""
@@ -321,6 +331,45 @@ describe Tmuxinator::Cli do
321
331
  include_examples :unsupported_version_message, :stop, :foo
322
332
  end
323
333
 
334
+ describe "#stop(with project config file)" do
335
+ before do
336
+ allow(Tmuxinator::Config).to receive(:validate).and_call_original
337
+ allow(Tmuxinator::Config).to receive_messages(version: 1.9)
338
+ allow(Kernel).to receive(:exec)
339
+ end
340
+
341
+ it "stops the project" do
342
+ ARGV.replace(["stop", "--project-config=#{project_config}"])
343
+ expect(Tmuxinator::Config).to receive_messages(validate: project)
344
+ expect(Kernel).to receive(:exec)
345
+ out, err = capture_io { cli.start }
346
+ expect(err).to eq ""
347
+ expect(out).to eq ""
348
+ end
349
+
350
+ it "does not stop the project if given a bogus project config file" do
351
+ ARGV.replace(["stop", "--project-config=bogus.yml"])
352
+ expect(Kernel).not_to receive(:exec)
353
+ expect { capture_io { cli.start } }.to raise_error(SystemExit)
354
+ end
355
+
356
+ it "does not set the project name" do
357
+ ARGV.replace(["stop", "--project-config=#{project_config}"])
358
+ expect(Tmuxinator::Config).
359
+ to(receive(:validate).
360
+ with(hash_including(name: nil)))
361
+ capture_io { cli.start }
362
+ end
363
+
364
+ it "does not set the project name even when set" do
365
+ ARGV.replace(["stop", "bar", "--project-config=#{project_config}"])
366
+ expect(Tmuxinator::Config).
367
+ to(receive(:validate).
368
+ with(hash_including(name: nil)))
369
+ capture_io { cli.start }
370
+ end
371
+ end
372
+
324
373
  describe "#local" do
325
374
  before do
326
375
  allow(Tmuxinator::Config).to receive_messages(validate: project)
@@ -650,7 +699,7 @@ describe Tmuxinator::Cli do
650
699
  end
651
700
 
652
701
  it "does not render the project if given a bogus project config file" do
653
- ARGV.replace(["start", "--project-config=bogus.yml"])
702
+ ARGV.replace(["debug", "--project-config=bogus.yml"])
654
703
  expect { capture_io { cli.start } }.to raise_error(SystemExit)
655
704
  end
656
705
  end
@@ -52,7 +52,7 @@ describe Tmuxinator::Config do
52
52
  allow(described_class).to receive(:home?).and_return false
53
53
 
54
54
  Dir.mktmpdir do |dir|
55
- config_parent = "#{dir}/non_existant_parent/s"
55
+ config_parent = "#{dir}/non_existent_parent/s"
56
56
  allow(XDG).to receive(:[]).with("CONFIG").and_return config_parent
57
57
  expect(described_class.directory).
58
58
  to eq "#{config_parent}/tmuxinator"
@@ -62,7 +62,7 @@ describe Tmuxinator::Config do
62
62
  end
63
63
  end
64
64
 
65
- describe "#enviroment" do
65
+ describe "#environment" do
66
66
  context "environment variable $TMUXINATOR_CONFIG is not empty" do
67
67
  it "is $TMUXINATOR_CONFIG" do
68
68
  allow(ENV).to receive(:[]).with("TMUXINATOR_CONFIG").
@@ -3,19 +3,20 @@ require "spec_helper"
3
3
  describe Tmuxinator::Pane do
4
4
  let(:klass) { described_class }
5
5
  let(:instance) { klass.new(index, project, window, *commands) }
6
- # let(:index) { "vim" }
7
- # let(:project) { 0 }
8
- # let(:tab) { nil }
9
- # let(:commands) { nil }
6
+ let(:instance_with_title) do
7
+ klass.new(index, project, window, *commands, title: title)
8
+ end
10
9
  let(:index) { 0 }
11
10
  let(:project) { double }
12
11
  let(:window) { double }
13
12
  let(:commands) { ["vim", "bash"] }
13
+ let(:title) { "test" }
14
14
 
15
15
  before do
16
16
  allow(project).to receive(:name).and_return "foo"
17
17
  allow(project).to receive(:base_index).and_return 0
18
18
  allow(project).to receive(:pane_base_index).and_return 1
19
+ allow(project).to receive(:tmux).and_return "tmux"
19
20
 
20
21
  allow(window).to receive(:project).and_return project
21
22
  allow(window).to receive(:index).and_return 0
@@ -28,4 +29,18 @@ describe Tmuxinator::Pane do
28
29
  end
29
30
 
30
31
  it { expect(subject.tmux_window_and_pane_target).to eql "foo:0.1" }
32
+
33
+ it "does not set pane title" do
34
+ expect(subject.tmux_set_title).to be_nil
35
+ end
36
+
37
+ context "when title is provided" do
38
+ subject { instance_with_title }
39
+
40
+ it "sets pane title" do
41
+ expect(subject.tmux_set_title).to eql(
42
+ "tmux select-pane -t foo:0.1 -T test"
43
+ )
44
+ end
45
+ end
31
46
  end
@@ -127,6 +127,26 @@ describe Tmuxinator::Window do
127
127
  end
128
128
  end
129
129
 
130
+ context "titled panes" do
131
+ let(:panes) do
132
+ [
133
+ { "editor" => ["vim"] },
134
+ { "run" => ["cmd1", "cmd2"] },
135
+ "top"
136
+ ]
137
+ end
138
+
139
+ it "creates panes with titles" do
140
+ expect(window.panes).to match(
141
+ [
142
+ a_pane.with(index: 0, title: "editor").and_commands("vim"),
143
+ a_pane.with(index: 1, title: "run").and_commands("cmd1", "cmd2"),
144
+ a_pane.with(index: 2, title: nil).and_commands("top")
145
+ ]
146
+ )
147
+ end
148
+ end
149
+
130
150
  context "nested collections" do
131
151
  let(:command1) { "cd /tmp/" }
132
152
  let(:command2) { "ls" }
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tmuxinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Allen Bargi
8
8
  - Christopher Chow
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-01-08 00:00:00.000000000 Z
12
+ date: 2024-02-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: erubis
@@ -302,8 +302,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
302
302
  - !ruby/object:Gem::Version
303
303
  version: 1.8.23
304
304
  requirements: []
305
- rubygems_version: 3.3.15
306
- signing_key:
305
+ rubygems_version: 3.2.33
306
+ signing_key:
307
307
  specification_version: 4
308
308
  summary: Create and manage complex tmux sessions easily.
309
309
  test_files: