tmuxinator 0.6.6.pre → 0.6.6.pre.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55331f23c1165f7baf76833639f87d594c1b3d44
4
- data.tar.gz: 3f8a57eae115f45286223641a72b3147309d10cd
3
+ metadata.gz: 8bcc4780395d82023d5e13e4bf7a9b71233a7f2c
4
+ data.tar.gz: 0a2cfa85b61822b272935a58306340f022567d8a
5
5
  SHA512:
6
- metadata.gz: 3ff12ea856474fee5fe315123c635f317161573f2762a7e22ff5100c7e1563db232c7ed563bad8aa198e7e24dfc708327932db2f736285f1dfe8ee656975b6d8
7
- data.tar.gz: b0136800e96359dcd2566ca3e57117655b5303d2facca41c378460fa811f8747463223bac0a353c51e3c0066320eb4129cd71289911b1573c9127cacf0a8489a
6
+ metadata.gz: 62293ddba08471509037579f4ed99f2d042bc985990bf0de5d41ebb52889f540b8f2fd08f4453d1b72c438abd8ba250fe707d5421220d0127d831c9ef6f8526e
7
+ data.tar.gz: 3ef6e0f06d6717b052d7bad8ed5cf3ca0f3b3a0ea0f85efc7901b90506f1453f54b8e166420a1c51343cdd51230f092a5ce200e45ef46a1e94a29473ee9f781c
data/.travis.yml CHANGED
@@ -2,4 +2,23 @@ language: ruby
2
2
  rvm:
3
3
  - "1.9.3"
4
4
  - "2.0.0"
5
+ env:
6
+ - TMUX_VERSION=master
7
+ - TMUX_VERSION=1.8
8
+ - TMUX_VERSION=1.7
9
+ - TMUX_VERSION=1.6
10
+ - TMUX_VERSION=1.5
11
+ matrix:
12
+ allow_failures:
13
+ - env: TMUX_VERSION=1.7
14
+ before_install:
15
+ - sudo apt-get update -qq
16
+ - sudo apt-get install -qq libevent-dev libncurses-dev
17
+ - git clone git://git.code.sf.net/p/tmux/tmux-code tmux
18
+ - cd tmux
19
+ - git checkout $TMUX_VERSION
20
+ - sh autogen.sh
21
+ - ./configure && make && sudo make install
22
+ - cd ..
23
+ - tmux -V
5
24
  script: bundle exec rspec spec
data/README.md CHANGED
@@ -144,6 +144,30 @@ pre_window: rbenv shell 2.0.0-p247
144
144
 
145
145
  These command(s) will run before any subsequent commands in all panes and windows.
146
146
 
147
+ ## Passing directly to send-keys
148
+
149
+ tmuxinator passes commands directly to send keys. This differs from simply chaining commands together using `&&` or `;`, in that
150
+ tmux will directly send the commands to shell as if you typed them in. This allows commands to be executed on a remote server over
151
+ SSH for example.
152
+
153
+ To support this both the window and pane options can take an array as an argument:
154
+
155
+ ```
156
+ name: sample
157
+ root: ~/
158
+
159
+ windows:
160
+ - stats:
161
+ - ssh stats@example.com
162
+ - tail -f /var/log/stats.log
163
+ - logs:
164
+ layout: main-vertical
165
+ panes:
166
+ - logs:
167
+ - ssh logs@example.com
168
+ - cd /var/logs
169
+ - tail -f development.log
170
+ ```
147
171
 
148
172
  ## Starting a session
149
173
 
@@ -23,14 +23,20 @@ if [ "$?" -eq 1 ]; then
23
23
  # Window "<%= window.name %>"
24
24
  <%- unless window.panes? -%>
25
25
  <%= window.tmux_pre_window_command %>
26
- <%- window.commands.each do |command| -%>
26
+ <%- window.commands.each do |command| -%>
27
27
  <%= command %>
28
- <%- end -%>
28
+ <%- end -%>
29
29
  <%- else -%>
30
30
  <%- window.panes.each do |pane| -%>
31
31
  <%= pane.tmux_pre_window_command %>
32
32
  <%= pane.tmux_pre_command %>
33
- <%= pane.tmux_main_command %>
33
+ <%- if pane.multiple_commands? %>
34
+ <%- pane.commands.each do |command| -%>
35
+ <%= pane.tmux_main_command(command) %>
36
+ <%- end -%>
37
+ <%- else -%>
38
+ <%= pane.tmux_main_command(commands.first) %>
39
+ <%- end -%>
34
40
 
35
41
  <%- unless pane.last? -%>
36
42
  <%= pane.tmux_split_command %>
@@ -1,9 +1,9 @@
1
1
  module Tmuxinator
2
2
  class Pane
3
- attr_reader :command, :project, :index, :project, :tab
3
+ attr_reader :commands, :project, :index, :project, :tab
4
4
 
5
- def initialize(command, index, project, tab)
6
- @command = command
5
+ def initialize(index, project, tab, *commands)
6
+ @commands = commands
7
7
  @index = index
8
8
  @project = project
9
9
  @tab = tab
@@ -21,7 +21,7 @@ module Tmuxinator
21
21
  project.pre_window.present? ? "#{project.tmux} send-keys -t #{tmux_window_and_pane_target} #{project.pre_window.shellescape} C-m" : ""
22
22
  end
23
23
 
24
- def tmux_main_command
24
+ def tmux_main_command(command)
25
25
  command.present? ? "#{project.tmux} send-keys -t #{project.name}:#{tab.index + project.base_index}.#{index + tab.project.base_index} #{command.shellescape} C-m" : ""
26
26
  end
27
27
 
@@ -32,5 +32,9 @@ module Tmuxinator
32
32
  def last?
33
33
  index == tab.panes.length - 1
34
34
  end
35
+
36
+ def multiple_commands?
37
+ commands.present? && commands.length > 0
38
+ end
35
39
  end
36
40
  end
@@ -15,12 +15,7 @@ module Tmuxinator
15
15
  end
16
16
 
17
17
  def windows
18
- windows_yml =
19
- if yaml["tabs"].present?
20
- yaml["tabs"]
21
- else
22
- yaml["windows"]
23
- end
18
+ windows_yml = yaml["tabs"].presence || yaml["windows"]
24
19
 
25
20
  @windows ||= windows_yml.map.with_index do |window_yml, index|
26
21
  Tmuxinator::Window.new(window_yml, index, self)
@@ -28,19 +23,11 @@ module Tmuxinator
28
23
  end
29
24
 
30
25
  def root
31
- if yaml["project_root"].present?
32
- yaml["project_root"]
33
- else
34
- yaml["root"]
35
- end
26
+ yaml["project_root"].presence || yaml["root"]
36
27
  end
37
28
 
38
29
  def name
39
- if yaml["project_name"].present?
40
- yaml["project_name"].shellescape
41
- else
42
- yaml["name"].shellescape
43
- end
30
+ yaml["project_name"].presence.try(:shellescape) || yaml["name"].shellescape
44
31
  end
45
32
 
46
33
  def pre
@@ -69,11 +56,7 @@ module Tmuxinator
69
56
  end
70
57
 
71
58
  def tmux_command
72
- if yaml["tmux_command"].present?
73
- yaml["tmux_command"]
74
- else
75
- "tmux"
76
- end
59
+ yaml["tmux_command"].presence || "tmux"
77
60
  end
78
61
 
79
62
  def socket
@@ -1,3 +1,3 @@
1
1
  module Tmuxinator
2
- VERSION = "0.6.6.pre"
2
+ VERSION = "0.6.6.pre.2"
3
3
  end
@@ -1,3 +1,5 @@
1
+ require "pry"
2
+
1
3
  module Tmuxinator
2
4
  class Window
3
5
  include Tmuxinator::Util
@@ -24,14 +26,16 @@ module Tmuxinator
24
26
  end
25
27
  end
26
28
 
27
- def build_panes(pane_yml)
28
- if pane_yml.is_a?(Array)
29
- pane_yml.map.with_index do |pane_cmd, index|
30
- Tmuxinator::Pane.new(pane_cmd, index, project, self)
29
+ def build_panes(panes_yml)
30
+ Array(panes_yml).map.with_index do |pane_yml, index|
31
+ if pane_yml.is_a?(Hash)
32
+ pane_yml.map do |name, commands|
33
+ Tmuxinator::Pane.new(index, project, self, *commands)
34
+ end
35
+ else
36
+ Tmuxinator::Pane.new(index, project, self, pane_yml)
31
37
  end
32
- else
33
- Tmuxinator::Pane.new(pane_yml, index, project, self)
34
- end
38
+ end.flatten
35
39
  end
36
40
 
37
41
  def build_commands(prefix, command_yml)
@@ -17,6 +17,9 @@ windows:
17
17
  - vim
18
18
  - #empty, will just run plain bash
19
19
  - top
20
+ - pane_with_multiple_commands:
21
+ - ssh server
22
+ - echo "Hello"
20
23
  - shell:
21
24
  - git pull
22
25
  - git merge
@@ -2,12 +2,13 @@ require "spec_helper"
2
2
 
3
3
  describe Tmuxinator::Window do
4
4
  let(:project) { double }
5
+ let(:panes) { ["vim", nil, "top"] }
5
6
  let(:yaml) do
6
7
  {
7
8
  "editor" => {
8
9
  "pre" => ["echo 'I get run in each pane. Before each pane command!'", nil],
9
10
  "layout" => "main-vertical",
10
- "panes" => ["vim", nil, "top"]
11
+ "panes" => panes
11
12
  }
12
13
  }
13
14
  end
@@ -24,9 +25,50 @@ describe Tmuxinator::Window do
24
25
  end
25
26
  end
26
27
 
27
- describe "#build_panes" do
28
- it "creates the list of panes" do
29
- expect(window.panes).to_not be_empty
28
+ describe "#panes" do
29
+ let(:pane) { double(:pane) }
30
+
31
+ before do
32
+ Tmuxinator::Pane.stub :new => pane
33
+ end
34
+
35
+ context "with a three element Array" do
36
+ let(:panes) { ["vim", nil, "top"] }
37
+
38
+ it "creates three panes" do
39
+ expect(Tmuxinator::Pane).to receive(:new).exactly(3).times
40
+ window.panes
41
+ end
42
+
43
+ it "returns three panes" do
44
+ expect(window.panes).to eql [pane, pane, pane]
45
+ end
46
+ end
47
+
48
+ context "with a String" do
49
+ let(:panes) { "vim" }
50
+
51
+ it "creates one pane" do
52
+ expect(Tmuxinator::Pane).to receive(:new).once
53
+ window.panes
54
+ end
55
+
56
+ it "returns one pane in an Array" do
57
+ expect(window.panes).to eql [pane]
58
+ end
59
+ end
60
+
61
+ context "with nil" do
62
+ let(:panes) { nil }
63
+
64
+ it "doesn't create any panes" do
65
+ expect(Tmuxinator::Pane).to_not receive(:new)
66
+ window.panes
67
+ end
68
+
69
+ it "returns an empty Array" do
70
+ expect(window.panes).to be_empty
71
+ end
30
72
  end
31
73
  end
32
74
 
@@ -85,18 +127,6 @@ describe Tmuxinator::Window do
85
127
  end
86
128
  end
87
129
 
88
- describe "#build_panes" do
89
- context "no panes" do
90
- before do
91
- yaml["editor"]["panes"] = "vim"
92
- end
93
-
94
- it "creates one pane" do
95
- expect(window.panes).to be_a(Tmuxinator::Pane)
96
- end
97
- end
98
- end
99
-
100
130
  describe "#tmux_new_window_command" do
101
131
  let(:project) { double(:project) }
102
132
  let(:window) { Tmuxinator::Window.new(yaml, 0, project) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tmuxinator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6.pre
4
+ version: 0.6.6.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Allen Bargi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-16 00:00:00.000000000 Z
11
+ date: 2013-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor