Initial commit
This commit is contained in:
commit
1f0d2fe405
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
*.gem
|
||||||
|
.rvmrc
|
||||||
|
.local*
|
35
README.mkd
Normal file
35
README.mkd
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
# What is this?
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
A work in progress. Will be a gem soon. You probably should not use it. Things will change.
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
$ teamocil sample
|
||||||
|
|
||||||
|
# Layout example
|
||||||
|
|
||||||
|
# ~/.teamocil/sample.yml
|
||||||
|
|
||||||
|
- cmd: cd ~/Code/sample/www
|
||||||
|
- cmd:
|
||||||
|
- cd ~/Code/sample/www
|
||||||
|
- rails s
|
||||||
|
width: 50
|
||||||
|
- cmd: memcached -p 11211 -vv
|
||||||
|
height: 25
|
||||||
|
|
||||||
|
will create a new window named `sample` with a layout like this:
|
||||||
|
|
||||||
|
.------------------.------------------.
|
||||||
|
| (0) | (1) |
|
||||||
|
| | |
|
||||||
|
| | |
|
||||||
|
| | |
|
||||||
|
| | |
|
||||||
|
| | |
|
||||||
|
| |------------------|
|
||||||
|
| | (2) |
|
||||||
|
| | |
|
||||||
|
'------------------'------------------'
|
6
bin/teamocil
Executable file
6
bin/teamocil
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require "teamocil"
|
||||||
|
|
||||||
|
layout = Teamocil::Layout.new(ARGV[0], File.join("#{ENV["HOME"]}/.teamocil", "#{ARGV[0]}.yml"))
|
||||||
|
layout.to_tmux
|
9
lib/teamocil.rb
Normal file
9
lib/teamocil.rb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
require 'yaml'
|
||||||
|
|
||||||
|
$:.unshift(File.dirname(__FILE__)) unless
|
||||||
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
||||||
|
|
||||||
|
module Teamocil
|
||||||
|
VERSION = '0.1'
|
||||||
|
autoload :Layout, "teamocil/layout"
|
||||||
|
end
|
52
lib/teamocil/layout.rb
Normal file
52
lib/teamocil/layout.rb
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
module Teamocil
|
||||||
|
class Layout
|
||||||
|
|
||||||
|
attr_accessor :config, :name
|
||||||
|
|
||||||
|
def initialize(name, file) # {{{
|
||||||
|
@layout = YAML.load_file(file)
|
||||||
|
@name = name
|
||||||
|
end # }}}
|
||||||
|
|
||||||
|
def to_tmux # {{{
|
||||||
|
commands = generate_commands
|
||||||
|
execute_commands(commands)
|
||||||
|
end # }}}
|
||||||
|
|
||||||
|
def generate_commands # {{{
|
||||||
|
output = []
|
||||||
|
|
||||||
|
@layout["windows"].each do |window|
|
||||||
|
|
||||||
|
output << "tmux new-window -n #{window["name"]}"
|
||||||
|
window["splits"].each_with_index do |split, index|
|
||||||
|
unless index == 0
|
||||||
|
if split.include?("width")
|
||||||
|
output << "tmux split-window -h -p #{split["width"]}"
|
||||||
|
else
|
||||||
|
if split.include?("height")
|
||||||
|
output << "tmux split-window -p #{split["height"]}"
|
||||||
|
else
|
||||||
|
output << "tmux split-window"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
split["cmd"] = [split["cmd"]] unless split["cmd"].is_a? Array
|
||||||
|
split["cmd"].each do |command|
|
||||||
|
output << "tmux send-keys -t #{index} \"#{command}\""
|
||||||
|
output << "tmux send-keys -t #{index} Enter"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
output << "tmux select-pane -t 0"
|
||||||
|
end # }}}
|
||||||
|
|
||||||
|
def execute_commands(commands) # {{{
|
||||||
|
`#{commands.join("; ")}`
|
||||||
|
end # }}}
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
10
script/console
Executable file
10
script/console
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env ruby
|
||||||
|
# File: script/console
|
||||||
|
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
||||||
|
|
||||||
|
libs = " -r irb/completion"
|
||||||
|
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
||||||
|
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
||||||
|
libs << " -r #{File.dirname(__FILE__) + '/../lib/teamocil.rb'}"
|
||||||
|
puts "Loading teamocil gem"
|
||||||
|
exec "#{irb} #{libs} --simple-prompt"
|
14
teamocil.gemspec
Normal file
14
teamocil.gemspec
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
spec = Gem::Specification.new do |s|
|
||||||
|
s.name = "teamocil"
|
||||||
|
s.version = "0.1"
|
||||||
|
s.platform = Gem::Platform::RUBY
|
||||||
|
s.authors = "Rémi Prévost"
|
||||||
|
s.email = "remi@exomel.com"
|
||||||
|
s.homepage = "http://github.com/remiprev/teamocil"
|
||||||
|
s.summary = "Easy window and split layouts for tmux"
|
||||||
|
s.description = "Teamocil helps you set up window and splits layouts for tmux using YAML configuration files."
|
||||||
|
s.files = Dir["lib/**/*.rb", "README.mkd", "LICENSE", "bin/*"]
|
||||||
|
s.require_path = "lib"
|
||||||
|
s.executables << 'teamocil'
|
||||||
|
end
|
||||||
|
|
3
test/test_helper.rb
Normal file
3
test/test_helper.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
require 'stringio'
|
||||||
|
require 'test/unit'
|
||||||
|
require File.dirname(__FILE__) + '/../lib/teamocil'
|
11
test/test_teamocil.rb
Normal file
11
test/test_teamocil.rb
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
require File.dirname(__FILE__) + '/test_helper.rb'
|
||||||
|
|
||||||
|
class TestTeamocil < Test::Unit::TestCase
|
||||||
|
|
||||||
|
def setup
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_truth
|
||||||
|
assert true
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user