tmuxinator 3.3.8 → 3.4.0

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.
@@ -73,10 +73,40 @@ describe Tmuxinator::Project do
73
73
  expect(project.render).to_not be_empty
74
74
  end
75
75
 
76
+ it "renders focused pane selection for a window" do
77
+ project.yaml["windows"][0]["editor"]["focused_pane"] = 2
78
+
79
+ expect(project.render).to include("select-pane -t sample:0.2")
80
+ end
81
+
82
+ it "renders startup pane selection when configured" do
83
+ project.yaml["startup_pane"] = 3
84
+
85
+ expect(project.render).to include("select-pane -t sample:0.3")
86
+ end
87
+
88
+ it "preserves first-pane startup selection when startup_pane is omitted" do
89
+ project.yaml["startup_window"] = "editor"
90
+ project.yaml["windows"][0]["editor"]["focused_pane"] = "guard"
91
+ project.yaml["windows"][0]["editor"]["panes"] = [
92
+ { "editor" => "vim" },
93
+ { "guard" => "bundle exec guard" }
94
+ ]
95
+
96
+ expect(project.render).to include("select-pane -t sample:0.1")
97
+ expect(project.render).to include("select-pane -t sample:editor.0")
98
+ end
99
+
76
100
  context "wemux" do
77
101
  it "renders the wemux config" do
78
102
  expect(wemux_project.render).to_not be_empty
79
103
  end
104
+
105
+ it "renders focused pane selection for a window" do
106
+ wemux_project.yaml["windows"][0]["editor"]["focused_pane"] = 2
107
+
108
+ expect(wemux_project.render).to include("select-pane -t wemux:0.2")
109
+ end
80
110
  end
81
111
 
82
112
  context "custom name" do
@@ -202,6 +232,22 @@ describe Tmuxinator::Project do
202
232
  end
203
233
  end
204
234
 
235
+ context "with dots" do
236
+ it "uses the session name tmux creates" do
237
+ project.yaml["project_name"] = "home.arpa"
238
+
239
+ expect(project.name).to eq "home_arpa"
240
+ end
241
+ end
242
+
243
+ context "with colons" do
244
+ it "uses the session name tmux creates" do
245
+ project.yaml["project_name"] = "home:arpa"
246
+
247
+ expect(project.name).to eq "home_arpa"
248
+ end
249
+ end
250
+
205
251
  context "as emoji" do
206
252
  it "will gracefully handle a name given as an emoji" do
207
253
  rendered = project_with_emoji_as_name
@@ -428,20 +474,57 @@ describe Tmuxinator::Project do
428
474
  end
429
475
  end
430
476
 
477
+ describe "#tmux_startup_pane_command" do
478
+ context "with integer" do
479
+ it "returns command with index" do
480
+ project.yaml["startup_pane"] = 1
481
+
482
+ expect(project.tmux_startup_pane_command).
483
+ to match("select-pane -t sample:0.1")
484
+ end
485
+ end
486
+
487
+ context "with nil" do
488
+ it "returns command for first pane in startup window" do
489
+ project.yaml["startup_pane"] = nil
490
+
491
+ expect(project.tmux_startup_pane_command).
492
+ to eq("tmux -f ~/.tmux.mac.conf -L foo select-pane -t sample:0.0")
493
+ end
494
+ end
495
+
496
+ context "with blank string" do
497
+ it "treats startup_pane as unset" do
498
+ project.yaml["startup_pane"] = ""
499
+
500
+ expect(project.tmux_startup_pane_command).
501
+ to eq("tmux -f ~/.tmux.mac.conf -L foo select-pane -t sample:0.0")
502
+ end
503
+ end
504
+ end
505
+
431
506
  describe "#startup_pane" do
432
- context "startup pane specified" do
433
- it "get the startup pane index from project config" do
507
+ context "with startup pane configured" do
508
+ it "returns the configured pane target" do
434
509
  project.yaml["startup_pane"] = 1
435
510
 
436
511
  expect(project.startup_pane).to eq("sample:0.1")
437
512
  end
438
513
  end
439
514
 
440
- context "startup pane not specified" do
441
- it "returns the base pane instead" do
442
- allow(project).to receive_messages(pane_base_index: 4)
515
+ context "with startup pane unset" do
516
+ it "returns the first pane in the startup window" do
517
+ project.yaml["startup_pane"] = nil
518
+
519
+ expect(project.startup_pane).to eq("sample:0.0")
520
+ end
521
+ end
522
+
523
+ context "with startup pane blank" do
524
+ it "treats the pane as unset" do
525
+ project.yaml["startup_pane"] = ""
443
526
 
444
- expect(project.startup_pane).to eq("sample:0.4")
527
+ expect(project.startup_pane).to eq("sample:0.0")
445
528
  end
446
529
  end
447
530
  end
@@ -5,6 +5,7 @@ require "spec_helper"
5
5
  describe Tmuxinator::Window do
6
6
  let(:project) { double }
7
7
  let(:panes) { ["vim", nil, "top"] }
8
+ let(:focused_pane) { nil }
8
9
  let(:window_name) { "editor" }
9
10
  let(:synchronize) { false }
10
11
  let(:root) {}
@@ -19,6 +20,7 @@ describe Tmuxinator::Window do
19
20
  "synchronize" => synchronize,
20
21
  "layout" => "main-vertical",
21
22
  "panes" => panes,
23
+ "focused_pane" => focused_pane,
22
24
  "root" => root,
23
25
  "root?" => root?,
24
26
  }
@@ -148,6 +150,106 @@ describe Tmuxinator::Window do
148
150
  end
149
151
  end
150
152
 
153
+ context "focused pane" do
154
+ let(:panes) do
155
+ [
156
+ { "editor" => ["vim"] },
157
+ { "run" => ["cmd1"] },
158
+ "top"
159
+ ]
160
+ end
161
+
162
+ context "with index" do
163
+ let(:focused_pane) { 1 }
164
+ it "focuses pane by index" do
165
+ expect(window.tmux_focus_pane_command).to eq("tmux select-pane -t test:1.1")
166
+ end
167
+ end
168
+
169
+ context "with quoted index" do
170
+ let(:focused_pane) { "1" }
171
+
172
+ it "focuses pane by index" do
173
+ expect(window.tmux_focus_pane_command).to eq("tmux select-pane -t test:1.1")
174
+ end
175
+ end
176
+
177
+ context "with invalid index" do
178
+ let(:focused_pane) { 5 }
179
+
180
+ it "falls back to first" do
181
+ expect(window.tmux_focus_pane_command).to eq("tmux select-pane -t test:1.0")
182
+ end
183
+ end
184
+
185
+ context "with invalid quoted index" do
186
+ let(:focused_pane) { "5" }
187
+
188
+ it "falls back to first" do
189
+ expect(window.tmux_focus_pane_command).to eq("tmux select-pane -t test:1.0")
190
+ end
191
+ end
192
+
193
+ context "with negative index" do
194
+ let(:focused_pane) { -1 }
195
+
196
+ it "falls back to first" do
197
+ expect(window.tmux_focus_pane_command).to eq("tmux select-pane -t test:1.0")
198
+ end
199
+ end
200
+
201
+ context "with negative quoted index" do
202
+ let(:focused_pane) { "-1" }
203
+
204
+ it "falls back to first" do
205
+ expect(window.tmux_focus_pane_command).to eq("tmux select-pane -t test:1.0")
206
+ end
207
+ end
208
+
209
+ context "with name" do
210
+ let(:focused_pane) { "run" }
211
+ it "focuses pane by name" do
212
+ expect(window.tmux_focus_pane_command).to eq("tmux select-pane -t test:1.1")
213
+ end
214
+ end
215
+
216
+ context "with shell-sensitive name" do
217
+ let(:panes) do
218
+ [
219
+ { "editor" => ["vim"] },
220
+ { "dev log" => ["tail -f log/development.log"] },
221
+ "top"
222
+ ]
223
+ end
224
+ let(:focused_pane) { "dev log" }
225
+
226
+ it "focuses pane by name" do
227
+ expect(window.tmux_focus_pane_command).to eq("tmux select-pane -t test:1.1")
228
+ end
229
+ end
230
+
231
+ context "with invalid name" do
232
+ let(:focused_pane) { "invalid" }
233
+ it "falls back to first" do
234
+ expect(window.tmux_focus_pane_command).to eq("tmux select-pane -t test:1.0")
235
+ end
236
+ end
237
+
238
+ context "with nil" do
239
+ let(:focused_pane) { nil }
240
+ it "focuses first pane" do
241
+ expect(window.tmux_focus_pane_command).to eq("tmux select-pane -t test:1.0")
242
+ end
243
+ end
244
+
245
+ context "with pane base index" do
246
+ it "adjusts for base index" do
247
+ allow(project).to receive_messages(pane_base_index: 3)
248
+ expect(window.tmux_focus_pane_command).to eq("tmux select-pane -t test:1.3")
249
+ end
250
+ end
251
+ end
252
+
151
253
  context "nested collections" do
152
254
  let(:command1) { "cd /tmp/" }
153
255
  let(:command2) { "ls" }
@@ -391,10 +493,4 @@ describe Tmuxinator::Window do
391
493
  end
392
494
  end
393
495
  end
394
-
395
- describe "#tmux_select_first_pane" do
396
- it "targets the pane based on the configured pane_base_index" do
397
- expect(window.tmux_select_first_pane).to eq("tmux select-pane -t test:1.0")
398
- end
399
- end
400
496
  end
@@ -0,0 +1,73 @@
1
+ #!/bin/bash
2
+
3
+
4
+ # Clear rbenv variables before starting tmux
5
+ unset RBENV_VERSION
6
+ unset RBENV_DIR
7
+
8
+ tmux -L interface start-server;
9
+
10
+ cd /workspace/basic
11
+
12
+ # Run on_project_start command.
13
+
14
+
15
+
16
+ # Run pre command.
17
+
18
+
19
+ # Run on_project_first_start command.
20
+
21
+
22
+ tmux -L interface new-session -d -s basic -n editor
23
+
24
+ # Set the default path for versions prior to 1.7
25
+ tmux -L interface set-option -t basic default-path /workspace/basic 1>/dev/null
26
+
27
+
28
+ # Create windows.
29
+ tmux -L interface new-window default-path /workspace/basic/app -k -t basic:0 -n editor
30
+ tmux -L interface new-window default-path /workspace/basic -k -t basic:1 -n shell
31
+
32
+
33
+ # Window "editor"
34
+
35
+
36
+ tmux -L interface send-keys -t basic:0.0 bundle\ exec\ ruby\ -v C-m
37
+ tmux -L interface send-keys -t basic:0.0 bundle\ exec\ vim C-m
38
+
39
+ tmux -L interface splitw default-path /workspace/basic/app -t basic:0
40
+ tmux -L interface select-layout -t basic:0 tiled
41
+ tmux -L interface send-keys -t basic:0.1 bundle\ exec\ ruby\ -v C-m
42
+ tmux -L interface send-keys -t basic:0.1 bundle\ exec\ rake\ test C-m
43
+
44
+ tmux -L interface select-layout -t basic:0 tiled
45
+
46
+ tmux -L interface select-layout -t basic:0
47
+ tmux -L interface select-pane -t basic:0.0
48
+
49
+
50
+ # Window "shell"
51
+
52
+
53
+ tmux -L interface send-keys -t basic:1.0 bundle\ exec\ ruby\ -v C-m
54
+ tmux -L interface send-keys -t basic:1.0 bin/setup C-m
55
+
56
+ tmux -L interface select-layout -t basic:1 tiled
57
+
58
+ tmux -L interface select-layout -t basic:1
59
+ tmux -L interface select-pane -t basic:1.0
60
+
61
+
62
+ tmux -L interface select-window -t basic:0
63
+ tmux -L interface select-pane -t basic:0.0
64
+
65
+ if [ -z "$TMUX" ]; then
66
+ tmux -L interface -u attach-session -t basic
67
+ else
68
+ tmux -L interface -u switch-client -t basic
69
+ fi
70
+
71
+
72
+
73
+ # Run on_project_exit command.
@@ -0,0 +1,61 @@
1
+ #!/bin/bash
2
+
3
+
4
+ # Clear rbenv variables before starting tmux
5
+ unset RBENV_VERSION
6
+ unset RBENV_DIR
7
+
8
+ tmux -L interface start-server;
9
+
10
+ cd /workspace/pane-titles
11
+
12
+ # Run on_project_start command.
13
+
14
+
15
+
16
+ # Run pre command.
17
+
18
+
19
+ # Run on_project_first_start command.
20
+
21
+
22
+ tmux -L interface new-session -d -s pane-titles -n editor
23
+
24
+ # Set the default path for versions prior to 1.7
25
+ tmux -L interface set-option -t pane-titles default-path /workspace/pane-titles 1>/dev/null
26
+
27
+ printf "\033[1;33mWARNING: You have enabled pane titles in your configuration, but the feature is not supported by your version of tmux.
28
+ Please consider upgrading to a version that supports it (tmux >=2.6).
29
+ \033[0m"
30
+
31
+ # Create windows.
32
+ tmux -L interface new-window default-path /workspace/pane-titles -k -t pane-titles:0 -n editor
33
+
34
+
35
+ # Window "editor"
36
+
37
+
38
+ tmux -L interface send-keys -t pane-titles:0.0 bundle\ exec\ vim C-m
39
+
40
+ tmux -L interface splitw default-path /workspace/pane-titles -t pane-titles:0
41
+ tmux -L interface select-layout -t pane-titles:0 tiled
42
+ tmux -L interface send-keys -t pane-titles:0.1 tail\ -f\ log/test.log C-m
43
+
44
+ tmux -L interface select-layout -t pane-titles:0 tiled
45
+
46
+ tmux -L interface select-layout -t pane-titles:0
47
+ tmux -L interface select-pane -t pane-titles:0.0
48
+
49
+
50
+ tmux -L interface select-window -t pane-titles:0
51
+ tmux -L interface select-pane -t pane-titles:0.0
52
+
53
+ if [ -z "$TMUX" ]; then
54
+ tmux -L interface -u attach-session -t pane-titles
55
+ else
56
+ tmux -L interface -u switch-client -t pane-titles
57
+ fi
58
+
59
+
60
+
61
+ # Run on_project_exit command.
@@ -0,0 +1,71 @@
1
+ #!/bin/bash
2
+
3
+
4
+ # Clear rbenv variables before starting tmux
5
+ unset RBENV_VERSION
6
+ unset RBENV_DIR
7
+
8
+ tmux -L interface start-server;
9
+
10
+ cd /workspace/basic
11
+
12
+ # Run on_project_start command.
13
+
14
+
15
+
16
+ # Run pre command.
17
+
18
+
19
+ # Run on_project_first_start command.
20
+
21
+
22
+ tmux -L interface new-session -d -s basic -n editor
23
+
24
+
25
+
26
+ # Create windows.
27
+ tmux -L interface new-window -c /workspace/basic/app -k -t basic:0 -n editor
28
+ tmux -L interface new-window -c /workspace/basic -k -t basic:1 -n shell
29
+
30
+
31
+ # Window "editor"
32
+
33
+
34
+ tmux -L interface send-keys -t basic:0.0 bundle\ exec\ ruby\ -v C-m
35
+ tmux -L interface send-keys -t basic:0.0 bundle\ exec\ vim C-m
36
+
37
+ tmux -L interface splitw -c /workspace/basic/app -t basic:0
38
+ tmux -L interface select-layout -t basic:0 tiled
39
+ tmux -L interface send-keys -t basic:0.1 bundle\ exec\ ruby\ -v C-m
40
+ tmux -L interface send-keys -t basic:0.1 bundle\ exec\ rake\ test C-m
41
+
42
+ tmux -L interface select-layout -t basic:0 tiled
43
+
44
+ tmux -L interface select-layout -t basic:0
45
+ tmux -L interface select-pane -t basic:0.0
46
+
47
+
48
+ # Window "shell"
49
+
50
+
51
+ tmux -L interface send-keys -t basic:1.0 bundle\ exec\ ruby\ -v C-m
52
+ tmux -L interface send-keys -t basic:1.0 bin/setup C-m
53
+
54
+ tmux -L interface select-layout -t basic:1 tiled
55
+
56
+ tmux -L interface select-layout -t basic:1
57
+ tmux -L interface select-pane -t basic:1.0
58
+
59
+
60
+ tmux -L interface select-window -t basic:0
61
+ tmux -L interface select-pane -t basic:0.0
62
+
63
+ if [ -z "$TMUX" ]; then
64
+ tmux -L interface -u attach-session -t basic
65
+ else
66
+ tmux -L interface -u switch-client -t basic
67
+ fi
68
+
69
+
70
+
71
+ # Run on_project_exit command.
@@ -0,0 +1,59 @@
1
+ #!/bin/bash
2
+
3
+
4
+ # Clear rbenv variables before starting tmux
5
+ unset RBENV_VERSION
6
+ unset RBENV_DIR
7
+
8
+ tmux -L interface start-server;
9
+
10
+ cd /workspace/pane-titles
11
+
12
+ # Run on_project_start command.
13
+
14
+
15
+
16
+ # Run pre command.
17
+
18
+
19
+ # Run on_project_first_start command.
20
+
21
+
22
+ tmux -L interface new-session -d -s pane-titles -n editor
23
+
24
+
25
+ printf "\033[1;33mWARNING: You have enabled pane titles in your configuration, but the feature is not supported by your version of tmux.
26
+ Please consider upgrading to a version that supports it (tmux >=2.6).
27
+ \033[0m"
28
+
29
+ # Create windows.
30
+ tmux -L interface new-window -c /workspace/pane-titles -k -t pane-titles:0 -n editor
31
+
32
+
33
+ # Window "editor"
34
+
35
+
36
+ tmux -L interface send-keys -t pane-titles:0.0 bundle\ exec\ vim C-m
37
+
38
+ tmux -L interface splitw -c /workspace/pane-titles -t pane-titles:0
39
+ tmux -L interface select-layout -t pane-titles:0 tiled
40
+ tmux -L interface send-keys -t pane-titles:0.1 tail\ -f\ log/test.log C-m
41
+
42
+ tmux -L interface select-layout -t pane-titles:0 tiled
43
+
44
+ tmux -L interface select-layout -t pane-titles:0
45
+ tmux -L interface select-pane -t pane-titles:0.0
46
+
47
+
48
+ tmux -L interface select-window -t pane-titles:0
49
+ tmux -L interface select-pane -t pane-titles:0.0
50
+
51
+ if [ -z "$TMUX" ]; then
52
+ tmux -L interface -u attach-session -t pane-titles
53
+ else
54
+ tmux -L interface -u switch-client -t pane-titles
55
+ fi
56
+
57
+
58
+
59
+ # Run on_project_exit command.
@@ -0,0 +1,74 @@
1
+ #!/bin/bash
2
+
3
+
4
+ # Clear rbenv variables before starting tmux
5
+ unset RBENV_VERSION
6
+ unset RBENV_DIR
7
+
8
+ tmux -L interface start-server;
9
+
10
+ cd /workspace/basic
11
+
12
+ # Run on_project_start command.
13
+
14
+
15
+
16
+ # Run pre command.
17
+
18
+
19
+ # Run on_project_first_start command.
20
+
21
+
22
+ tmux -L interface new-session -d -s basic -n editor
23
+
24
+
25
+
26
+ # Create windows.
27
+ tmux -L interface new-window -c /workspace/basic/app -k -t basic:0 -n editor
28
+ tmux -L interface new-window -c /workspace/basic -k -t basic:1 -n shell
29
+
30
+
31
+ # Window "editor"
32
+
33
+
34
+
35
+ tmux -L interface send-keys -t basic:0.0 bundle\ exec\ ruby\ -v C-m
36
+ tmux -L interface send-keys -t basic:0.0 bundle\ exec\ vim C-m
37
+
38
+ tmux -L interface splitw -c /workspace/basic/app -t basic:0
39
+ tmux -L interface select-layout -t basic:0 tiled
40
+
41
+ tmux -L interface send-keys -t basic:0.1 bundle\ exec\ ruby\ -v C-m
42
+ tmux -L interface send-keys -t basic:0.1 bundle\ exec\ rake\ test C-m
43
+
44
+ tmux -L interface select-layout -t basic:0 tiled
45
+
46
+ tmux -L interface select-layout -t basic:0
47
+ tmux -L interface select-pane -t basic:0.0
48
+
49
+
50
+ # Window "shell"
51
+
52
+
53
+
54
+ tmux -L interface send-keys -t basic:1.0 bundle\ exec\ ruby\ -v C-m
55
+ tmux -L interface send-keys -t basic:1.0 bin/setup C-m
56
+
57
+ tmux -L interface select-layout -t basic:1 tiled
58
+
59
+ tmux -L interface select-layout -t basic:1
60
+ tmux -L interface select-pane -t basic:1.0
61
+
62
+
63
+ tmux -L interface select-window -t basic:0
64
+ tmux -L interface select-pane -t basic:0.0
65
+
66
+ if [ -z "$TMUX" ]; then
67
+ tmux -L interface -u attach-session -t basic
68
+ else
69
+ tmux -L interface -u switch-client -t basic
70
+ fi
71
+
72
+
73
+
74
+ # Run on_project_exit command.
@@ -0,0 +1,60 @@
1
+ #!/bin/bash
2
+
3
+
4
+ # Clear rbenv variables before starting tmux
5
+ unset RBENV_VERSION
6
+ unset RBENV_DIR
7
+
8
+ tmux -L interface start-server;
9
+
10
+ cd /workspace/pane-titles
11
+
12
+ # Run on_project_start command.
13
+
14
+
15
+
16
+ # Run pre command.
17
+
18
+
19
+ # Run on_project_first_start command.
20
+
21
+
22
+ tmux -L interface new-session -d -s pane-titles -n editor
23
+
24
+
25
+
26
+ # Create windows.
27
+ tmux -L interface new-window -c /workspace/pane-titles -k -t pane-titles:0 -n editor
28
+
29
+
30
+ # Window "editor"
31
+
32
+ tmux -L interface set-window-option -t pane-titles:0 pane-border-status bottom
33
+ tmux -L interface set-window-option -t pane-titles:0 pane-border-format "[ #T ]"
34
+
35
+ tmux -L interface select-pane -t pane-titles:0.0 -T editor
36
+ tmux -L interface send-keys -t pane-titles:0.0 bundle\ exec\ vim C-m
37
+
38
+ tmux -L interface splitw -c /workspace/pane-titles -t pane-titles:0
39
+ tmux -L interface select-layout -t pane-titles:0 tiled
40
+ tmux -L interface select-pane -t pane-titles:0.1 -T logs
41
+ tmux -L interface send-keys -t pane-titles:0.1 tail\ -f\ log/test.log C-m
42
+
43
+ tmux -L interface select-layout -t pane-titles:0 tiled
44
+
45
+ tmux -L interface select-layout -t pane-titles:0
46
+ tmux -L interface select-pane -t pane-titles:0.0
47
+
48
+
49
+ tmux -L interface select-window -t pane-titles:0
50
+ tmux -L interface select-pane -t pane-titles:0.0
51
+
52
+ if [ -z "$TMUX" ]; then
53
+ tmux -L interface -u attach-session -t pane-titles
54
+ else
55
+ tmux -L interface -u switch-client -t pane-titles
56
+ fi
57
+
58
+
59
+
60
+ # Run on_project_exit command.