teamocil 0.1

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.
data/LICENSE ADDED
@@ -0,0 +1,3 @@
1
+ Copyright 2011 Rémi Prévost.
2
+ You may use this work without restrictions, as long as this notice is included.
3
+ The work is provided "as is" without warranty of any kind, neither express nor implied.
@@ -0,0 +1,46 @@
1
+ # Introduction
2
+
3
+ Teamocil is a tool used to automatically create windows and splits in `tmux` with Ruby and YAML. Like [tmuxinator](https://github.com/aziz/tmuxinator), but with splits, not just windows.
4
+
5
+ # Usage
6
+
7
+ $ gem install teamocil
8
+ $ mkdir ~/.teamocil
9
+ $ touch ~/.teamocil/sample.yml
10
+ $ teamocil sample
11
+
12
+ # Layout example
13
+
14
+ # ~/.teamocil/sample.yml
15
+
16
+ windows:
17
+ - name: sample-window
18
+ splits:
19
+ - cmd: cd ~/Code/sample/www
20
+ - cmd:
21
+ - cd ~/Code/sample/www
22
+ - rails s
23
+ width: 50
24
+ - cmd: memcached -p 11211 -vv
25
+ height: 25
26
+ - name: sample-window-2
27
+ splits:
28
+ - cmd: cd ~/Code/sample/www-2
29
+ - cmd:
30
+ - cd ~/Code/sample/www-2
31
+ - rails s
32
+ width: 50
33
+
34
+ will create a new window named `sample` with a layout like this:
35
+
36
+ .------------------.------------------.
37
+ | (0) | (1) |
38
+ | | |
39
+ | | |
40
+ | | |
41
+ | | |
42
+ | | |
43
+ | |------------------|
44
+ | | (2) |
45
+ | | |
46
+ '------------------'------------------'
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "teamocil"
4
+
5
+ layout = Teamocil::Layout.new(ARGV[0], File.join("#{ENV["HOME"]}/.teamocil", "#{ARGV[0]}.yml"))
6
+ layout.to_tmux
@@ -0,0 +1,9 @@
1
+ require 'yaml'
2
+
3
+ $:.unshift(File.dirname(__FILE__)) unless
4
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
5
+
6
+ module Teamocil
7
+ VERSION = '0.1'
8
+ autoload :Layout, "teamocil/layout"
9
+ end
@@ -0,0 +1,52 @@
1
+ module Teamocil
2
+ class Layout
3
+
4
+ attr_accessor :config, :name
5
+
6
+ def initialize(name, file) # {{{
7
+ @layout = YAML.load_file(file)
8
+ @name = name
9
+ end # }}}
10
+
11
+ def to_tmux # {{{
12
+ commands = generate_commands
13
+ execute_commands(commands)
14
+ end # }}}
15
+
16
+ def generate_commands # {{{
17
+ output = []
18
+
19
+ @layout["windows"].each do |window|
20
+
21
+ output << "tmux new-window -n #{window["name"]}"
22
+ window["splits"].each_with_index do |split, index|
23
+ unless index == 0
24
+ if split.include?("width")
25
+ output << "tmux split-window -h -p #{split["width"]}"
26
+ else
27
+ if split.include?("height")
28
+ output << "tmux split-window -p #{split["height"]}"
29
+ else
30
+ output << "tmux split-window"
31
+ end
32
+ end
33
+ end
34
+
35
+ split["cmd"] = [split["cmd"]] unless split["cmd"].is_a? Array
36
+ split["cmd"].each do |command|
37
+ output << "tmux send-keys -t #{index} \"#{command}\""
38
+ output << "tmux send-keys -t #{index} Enter"
39
+ end
40
+ end
41
+
42
+ end
43
+
44
+ output << "tmux select-pane -t 0"
45
+ end # }}}
46
+
47
+ def execute_commands(commands) # {{{
48
+ `#{commands.join("; ")}`
49
+ end # }}}
50
+
51
+ end
52
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: teamocil
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ version: "0.1"
10
+ platform: ruby
11
+ authors:
12
+ - "R\xC3\xA9mi Pr\xC3\xA9vost"
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-02-05 00:00:00 -05:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: Teamocil helps you set up window and splits layouts for tmux using YAML configuration files.
22
+ email: remi@exomel.com
23
+ executables:
24
+ - teamocil
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - lib/teamocil/layout.rb
31
+ - lib/teamocil.rb
32
+ - README.mkd
33
+ - LICENSE
34
+ - bin/teamocil
35
+ has_rdoc: true
36
+ homepage: http://github.com/remiprev/teamocil
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ hash: 3
50
+ segments:
51
+ - 0
52
+ version: "0"
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ requirements: []
63
+
64
+ rubyforge_project:
65
+ rubygems_version: 1.5.0
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: Easy window and split layouts for tmux
69
+ test_files: []
70
+