teamocil/bin/teamocil
Rémi Prévost b0bcd52f7e Add --layout option to specifiy a layout file
Thanks to Esa-Matti Suuronen on GitHub for the suggestion!
2011-02-24 20:58:38 -05:00

43 lines
882 B
Ruby
Executable File

#!/usr/bin/env ruby
def bail(msg)
puts msg
exit(1)
end
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
require 'yaml'
require 'teamocil'
require 'optparse'
bail "You must be in a tmux session to use teamocil" unless ENV["TMUX"]
options = {}
opts = OptionParser.new do |opts|
opts.banner = "Usage: teamocil [options] <layout>
Options:
"
opts.on("--here", "Set up the first window in the current window") do
options[:here] = true
end
opts.on("--layout [LAYOUT]", "Use a specific layout file, instead of ~/.teamocil/<layout>.yml") do |layout|
options[:layout] = layout
end
end
opts.parse!
if options.include?(:layout)
file = options[:layout]
else
file = File.join("#{ENV["HOME"]}/.teamocil", "#{ARGV[0]}.yml")
end
bail "There is no file \"#{file}\"" unless File.exists?(file)
layout = Teamocil::Layout.new(file, options)
layout.to_tmux