teamocil 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/LICENSE +1 -1
- data/README.md +5 -2
- data/lib/teamocil/cli.rb +6 -2
- data/lib/teamocil/layout/pane.rb +2 -2
- data/lib/teamocil/layout/session.rb +2 -0
- data/lib/teamocil/layout/window.rb +4 -1
- data/lib/teamocil/version.rb +1 -1
- data/spec/cli_spec.rb +8 -3
- data/spec/fixtures/layouts.yml +25 -0
- data/spec/layout_spec.rb +17 -0
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
ODgwOTgyYmFlMjUzMTA4ZjNlNTlhZmJlYzEyNTdkYmQ5OTQyOGY5ZjMwMzdi
|
10
|
-
NzQ3ZDE2NzRjNTA3NjAwNGU2NWNhOTA0ZWU2YjY3MjAyY2I3NWRmZjljN2M1
|
11
|
-
Nzg5ODJhMmE4YTI3YTE4YzA3MDU0ZmRkZGE3ZDEyMTk0ZjhjNjc=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NDFhZjFmYWIyNTMzNjAyMTYyNjI2ODhkNDBmMWJlOGU0NjkzMGY5NTliMzA3
|
14
|
-
MjI5NGEzMmExOWQ3M2QzYzNiN2QwMDA3YTdiZjNhN2JjMDM5NjQ1MjRjZjY3
|
15
|
-
ODk1MDNhZWI0MjMyMDc3ZmJhMjM0MjIzZTYyMmFlZGViNjQyOGE=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ae4d2a262a756ec11e9a2e0f2be1c6bc8ecdfafe
|
4
|
+
data.tar.gz: 4e5afa56cb394b6d433d16680e304b2776ae91e2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5373b8ca262482ad3166bd046565bf8a96f68d7ac8c93d0cc8f9ba0ca3cff1ef40c036951e656cb518d1cf7c174f4936c67159f7d8a46eae5a33ac8643cbdea8
|
7
|
+
data.tar.gz: d589b51c3cb65f77e3d4a78fa072a2c0206ecf7551e48d1b1a9bbd5a5358aac1fbdcc86c59a1fef3e0d66b93f4a2497539e5ca6f836d42fead7a24c2fd2c6eda
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2011-
|
1
|
+
Copyright (c) 2011-2014 Rémi Prévost
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
4
|
|
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
# Teamocil
|
1
|
+
# Teamocil
|
2
|
+
|
3
|
+
<a href="https://rubygems.org/gems/teamocil"><img src="http://img.shields.io/gem/v/teamocil.svg" /></a>
|
4
|
+
<a href="https://travis-ci.org/remiprev/teamocil"><img src="http://img.shields.io/travis/remiprev/teamocil.svg" /></a>
|
2
5
|
|
3
6
|
Teamocil is a simple tool used to automatically create sessions, windows and panes in [tmux](http://tmux.sourceforge.net/) with YAML files.
|
4
7
|
|
@@ -241,4 +244,4 @@ Take a look at the `spec` folder before you do, and make sure `bundle exec rake
|
|
241
244
|
|
242
245
|
## License
|
243
246
|
|
244
|
-
Teamocil is © 2011-
|
247
|
+
Teamocil is © 2011-2014 [Rémi Prévost](http://exomel.com) and may be freely distributed under the [MIT license](https://github.com/remiprev/teamocil/blob/master/LICENSE). See the `LICENSE` file.
|
data/lib/teamocil/cli.rb
CHANGED
@@ -20,6 +20,10 @@ module Teamocil
|
|
20
20
|
return print_layouts
|
21
21
|
end
|
22
22
|
|
23
|
+
if @options[:layout].nil? && argv[0].nil?
|
24
|
+
bail "You must supply a layout for teamocil to use. See `teamocil --help` for more options."
|
25
|
+
end
|
26
|
+
|
23
27
|
file = @options[:layout] || ::File.join(layout_path, "#{argv[0]}.yml")
|
24
28
|
|
25
29
|
if @options[:edit]
|
@@ -29,8 +33,8 @@ module Teamocil
|
|
29
33
|
::FileUtils.touch file unless File.exists?(file)
|
30
34
|
Kernel.system("cat \"#{file}\"")
|
31
35
|
else
|
32
|
-
bail "There is no file \"#{file}\"" unless File.exists?(file)
|
33
|
-
bail "You must be in a tmux session to use teamocil" unless env["TMUX"]
|
36
|
+
bail "There is no file \"#{file}\"." unless File.exists?(file)
|
37
|
+
bail "You must be in a tmux session to use teamocil." unless env["TMUX"]
|
34
38
|
|
35
39
|
yaml = ERB.new(File.read(file)).result
|
36
40
|
|
data/lib/teamocil/layout/pane.rb
CHANGED
@@ -50,13 +50,13 @@ module Teamocil
|
|
50
50
|
# Set the TEAMOCIL environment variable
|
51
51
|
# depending on the shell set in ENV
|
52
52
|
if ENV['SHELL'].scan(/fish/).empty?
|
53
|
-
@cmd.unshift "export TEAMOCIL=1"
|
53
|
+
@cmd.unshift "export TEAMOCIL=1" if @window.with_env_var
|
54
54
|
else
|
55
55
|
@cmd.unshift "set -gx TEAMOCIL 1"
|
56
56
|
end
|
57
57
|
|
58
58
|
# Execute each pane command
|
59
|
-
commands << "tmux send-keys -t #{@index} \"#{@cmd.flatten.compact.join(
|
59
|
+
commands << "tmux send-keys -t #{@index} \"#{@cmd.flatten.compact.join(@window.cmd_separator)}\""
|
60
60
|
commands << "tmux send-keys -t #{@index} Enter"
|
61
61
|
|
62
62
|
commands
|
@@ -22,6 +22,8 @@ module Teamocil
|
|
22
22
|
commands = []
|
23
23
|
commands << "tmux rename-session \"#{@name}\"" unless @name.nil?
|
24
24
|
commands << @windows.map(&:generate_commands)
|
25
|
+
@windows.each { |w| commands << "tmux select-window -t:#{w.name}" && break if w.focus }
|
26
|
+
commands
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
@@ -2,7 +2,7 @@ module Teamocil
|
|
2
2
|
class Layout
|
3
3
|
# This class represents a window within tmux
|
4
4
|
class Window
|
5
|
-
attr_reader :filters, :root, :panes, :options, :index, :name, :clear, :layout
|
5
|
+
attr_reader :filters, :focus, :root, :panes, :options, :index, :name, :clear, :layout, :with_env_var, :cmd_separator
|
6
6
|
|
7
7
|
# Initialize a new tmux window
|
8
8
|
#
|
@@ -12,9 +12,12 @@ module Teamocil
|
|
12
12
|
def initialize(session, index, attrs={})
|
13
13
|
@name = attrs["name"] || "teamocil-window-#{index+1}"
|
14
14
|
@root = attrs["root"] || "."
|
15
|
+
@with_env_var = attrs["with_env_var"] || (true if attrs["with_env_var"].nil?)
|
16
|
+
@cmd_separator = attrs["cmd_separator"] || "; "
|
15
17
|
@clear = attrs["clear"] == true ? "clear" : nil
|
16
18
|
@options = attrs["options"] || {}
|
17
19
|
@layout = attrs["layout"]
|
20
|
+
@focus = attrs["focus"]
|
18
21
|
|
19
22
|
@panes = attrs["panes"] || attrs["splits"] || []
|
20
23
|
raise Teamocil::Error::LayoutError.new("You must specify a `panes` (or legacy `splits`) key for every window.") if @panes.empty?
|
data/lib/teamocil/version.rb
CHANGED
data/spec/cli_spec.rb
CHANGED
@@ -31,9 +31,14 @@ describe Teamocil::CLI do
|
|
31
31
|
@cli.layout.session.windows.last.name.should == "bar"
|
32
32
|
end
|
33
33
|
|
34
|
+
it "fails to launch if no layout is provided" do
|
35
|
+
expect { @cli = Teamocil::CLI.new([], @fake_env) }.to raise_error SystemExit
|
36
|
+
Teamocil::CLI.messages.should include("You must supply a layout for teamocil to use. See `teamocil --help` for more options.")
|
37
|
+
end
|
38
|
+
|
34
39
|
it "fails to create a layout from a layout that doesn’t exist" do
|
35
40
|
expect { @cli = Teamocil::CLI.new(["i-do-not-exist"], @fake_env) }.to raise_error SystemExit
|
36
|
-
Teamocil::CLI.messages.should include("There is no file \"#{File.join(File.dirname(__FILE__), "fixtures", ".teamocil", "i-do-not-exist.yml")}\"")
|
41
|
+
Teamocil::CLI.messages.should include("There is no file \"#{File.join(File.dirname(__FILE__), "fixtures", ".teamocil", "i-do-not-exist.yml")}\".")
|
37
42
|
end
|
38
43
|
|
39
44
|
it "creates a layout from a specific file" do
|
@@ -46,7 +51,7 @@ describe Teamocil::CLI do
|
|
46
51
|
|
47
52
|
it "fails to create a layout from a file that doesn’t exist" do
|
48
53
|
expect { @cli = Teamocil::CLI.new(["--layout", "./spec/fixtures/.teamocil/i-do-not-exist.yml"], @fake_env) }.to raise_error SystemExit
|
49
|
-
Teamocil::CLI.messages.should include("There is no file \"./spec/fixtures/.teamocil/i-do-not-exist.yml\"")
|
54
|
+
Teamocil::CLI.messages.should include("There is no file \"./spec/fixtures/.teamocil/i-do-not-exist.yml\".")
|
50
55
|
end
|
51
56
|
|
52
57
|
it "lists available layouts" do
|
@@ -67,7 +72,7 @@ describe Teamocil::CLI do
|
|
67
72
|
@cli.layout.session.name.should == "sample-3"
|
68
73
|
|
69
74
|
expect { @cli = Teamocil::CLI.new(["sample"], @fake_env) }.to raise_error SystemExit
|
70
|
-
Teamocil::CLI.messages.should include("There is no file \"#{@fake_env["TEAMOCIL_PATH"]}/sample.yml\"")
|
75
|
+
Teamocil::CLI.messages.should include("There is no file \"#{@fake_env["TEAMOCIL_PATH"]}/sample.yml\".")
|
71
76
|
end
|
72
77
|
end
|
73
78
|
end
|
data/spec/fixtures/layouts.yml
CHANGED
@@ -4,6 +4,7 @@ two-windows:
|
|
4
4
|
- name: "foo"
|
5
5
|
clear: true
|
6
6
|
root: "/foo"
|
7
|
+
focus: true
|
7
8
|
layout: "tiled"
|
8
9
|
panes:
|
9
10
|
- cmd: "echo 'foo'"
|
@@ -36,6 +37,30 @@ two-windows-with-filters:
|
|
36
37
|
- cmd: "echo 'foo again'"
|
37
38
|
width: 50
|
38
39
|
|
40
|
+
two-windows-with-custom-command-options:
|
41
|
+
windows:
|
42
|
+
- name: "foo"
|
43
|
+
cmd_separator: "\n"
|
44
|
+
with_env_var: false
|
45
|
+
clear: true
|
46
|
+
root: "/foo"
|
47
|
+
layout: "tiled"
|
48
|
+
panes:
|
49
|
+
- cmd: "echo 'foo'"
|
50
|
+
- cmd: "echo 'foo again'"
|
51
|
+
- name: "bar"
|
52
|
+
cmd_separator: " && "
|
53
|
+
with_env_var: true
|
54
|
+
root: "/bar"
|
55
|
+
splits:
|
56
|
+
- cmd:
|
57
|
+
- "echo 'bar'"
|
58
|
+
- "echo 'bar in an array'"
|
59
|
+
target: bottom-right
|
60
|
+
- cmd: "echo 'bar again'"
|
61
|
+
focus: true
|
62
|
+
width: 50
|
63
|
+
|
39
64
|
three-windows-within-a-session:
|
40
65
|
session:
|
41
66
|
name: "my awesome session"
|
data/spec/layout_spec.rb
CHANGED
@@ -61,6 +61,11 @@ describe Teamocil::Layout do
|
|
61
61
|
session.windows[0].layout.should == "tiled"
|
62
62
|
session.windows[1].layout.should be_nil
|
63
63
|
end
|
64
|
+
|
65
|
+
it "handles focused windows" do
|
66
|
+
session = @layout.compile!
|
67
|
+
session.windows.first.focus.should be_true
|
68
|
+
end
|
64
69
|
end
|
65
70
|
|
66
71
|
describe "panes" do
|
@@ -208,5 +213,17 @@ describe Teamocil::Layout do
|
|
208
213
|
commands.last.should == "tmux send-keys -t 2 Enter"
|
209
214
|
end
|
210
215
|
end
|
216
|
+
|
217
|
+
it "should not export TEAMOCIL = 1 env variable if disabled" do
|
218
|
+
@layout = Teamocil::Layout.new(layouts["two-windows-with-custom-command-options"], {})
|
219
|
+
|
220
|
+
session = @layout.compile!
|
221
|
+
commands = session.windows.first.generate_commands
|
222
|
+
commands[1][0].should == ["tmux send-keys -t 0 \"cd \"/foo\"\nclear\necho 'foo'\"", "tmux send-keys -t 0 Enter", "tmux select-layout \"tiled\""]
|
223
|
+
commands[1][1].should == ["tmux split-window", "tmux send-keys -t 1 \"cd \"/foo\"\nclear\necho 'foo again'\"", "tmux send-keys -t 1 Enter", "tmux select-layout \"tiled\""]
|
224
|
+
|
225
|
+
commands = session.windows[1].generate_commands
|
226
|
+
commands[1][0].should == ["tmux send-keys -t 0 \"export TEAMOCIL=1 && cd \"/bar\" && echo 'bar' && echo 'bar in an array'\"", "tmux send-keys -t 0 Enter"]
|
227
|
+
end
|
211
228
|
end
|
212
229
|
end
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teamocil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rémi Prévost
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '2.13'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.13'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: yard
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: maruku
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Teamocil helps you set up window and pane layouts for tmux using YAML
|
@@ -74,8 +74,8 @@ executables:
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
-
- .gitignore
|
78
|
-
- .travis.yml
|
77
|
+
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
79
79
|
- Gemfile
|
80
80
|
- LICENSE
|
81
81
|
- README.md
|
@@ -114,17 +114,17 @@ require_paths:
|
|
114
114
|
- lib
|
115
115
|
required_ruby_version: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
|
-
- -
|
117
|
+
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
126
|
rubyforge_project:
|
127
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.2.2
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: Easy session, window and pane layouts for tmux
|