teamocil 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/teamocil +30 -6
- data/lib/teamocil/layout.rb +9 -5
- data/lib/teamocil.rb +1 -6
- metadata +4 -4
data/bin/teamocil
CHANGED
@@ -1,10 +1,34 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
def bail(msg)
|
4
|
+
puts msg
|
5
|
+
exit(1)
|
6
|
+
end
|
7
|
+
|
8
|
+
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
9
|
+
|
10
|
+
require 'yaml'
|
11
|
+
require 'teamocil'
|
12
|
+
require 'optparse'
|
13
|
+
|
14
|
+
bail "You must be in a tmux session to use teamocil" unless ENV["TMUX"]
|
15
|
+
|
16
|
+
options = {}
|
17
|
+
opts = OptionParser.new do |opts|
|
18
|
+
opts.banner = "Usage: teamocil [options] <layout>
|
19
|
+
|
20
|
+
Options:
|
21
|
+
"
|
22
|
+
opts.on("--here", "Set up the first window in the current window") do |safe|
|
23
|
+
options[:here] = true
|
24
|
+
end
|
4
25
|
|
5
|
-
if ENV["TMUX"] == nil
|
6
|
-
puts "You must be in a tmux session to use teamocil"
|
7
|
-
else
|
8
|
-
layout = Teamocil::Layout.new(ARGV[0], File.join("#{ENV["HOME"]}/.teamocil", "#{ARGV[0]}.yml"))
|
9
|
-
layout.to_tmux
|
10
26
|
end
|
27
|
+
opts.parse!
|
28
|
+
|
29
|
+
file = File.join("#{ENV["HOME"]}/.teamocil", "#{ARGV[0]}.yml")
|
30
|
+
|
31
|
+
bail "There is no file \"#{file}\"" unless File.exists?(file)
|
32
|
+
|
33
|
+
layout = Teamocil::Layout.new(file, options)
|
34
|
+
layout.to_tmux
|
data/lib/teamocil/layout.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Teamocil
|
2
2
|
class Layout
|
3
3
|
|
4
|
-
attr_accessor :
|
4
|
+
attr_accessor :layout, :options
|
5
5
|
|
6
|
-
def initialize(
|
6
|
+
def initialize(file, options) # {{{
|
7
7
|
@layout = YAML.load_file(file)
|
8
|
-
@
|
8
|
+
@options = options
|
9
9
|
end # }}}
|
10
10
|
|
11
11
|
def to_tmux # {{{
|
@@ -16,9 +16,13 @@ module Teamocil
|
|
16
16
|
def generate_commands # {{{
|
17
17
|
output = []
|
18
18
|
|
19
|
-
@layout["windows"].
|
19
|
+
@layout["windows"].each_with_index do |window, window_index|
|
20
20
|
|
21
|
-
|
21
|
+
if options.include?(:here) and window_index == 0
|
22
|
+
output << "tmux rename-window #{window["name"]}"
|
23
|
+
else
|
24
|
+
output << "tmux new-window -n #{window["name"]}"
|
25
|
+
end
|
22
26
|
window["splits"].each_with_index do |split, index|
|
23
27
|
unless index == 0
|
24
28
|
if split.include?("width")
|
data/lib/teamocil.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teamocil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "R\xC3\xA9mi Pr\xC3\xA9vost"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-16 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|