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 CHANGED
@@ -1,10 +1,34 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require File.dirname(__FILE__)+"/../lib/teamocil"
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
@@ -1,11 +1,11 @@
1
1
  module Teamocil
2
2
  class Layout
3
3
 
4
- attr_accessor :config, :name
4
+ attr_accessor :layout, :options
5
5
 
6
- def initialize(name, file) # {{{
6
+ def initialize(file, options) # {{{
7
7
  @layout = YAML.load_file(file)
8
- @name = name
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"].each do |window|
19
+ @layout["windows"].each_with_index do |window, window_index|
20
20
 
21
- output << "tmux new-window -n #{window["name"]}"
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
@@ -1,9 +1,4 @@
1
- require 'yaml'
2
-
3
- $:.unshift(File.dirname(__FILE__)) unless
4
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
5
-
6
1
  module Teamocil
7
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
8
3
  autoload :Layout, "teamocil/layout"
9
4
  end
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: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
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-05 00:00:00 -05:00
18
+ date: 2011-02-16 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies: []
21
21