Sha256: fdd9cbb50915d1e3d5d98d44c116d511828f99732adc9a12599d566f66beff64

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

#!/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("--edit", "Edit the YAML layout file instead of using it") do
    options[:edit] = 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)

if options[:edit]
  system("$EDITOR \"#{file}\"")
else
  layout = Teamocil::Layout.new(file, options)
  layout.to_tmux
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
teamocil-0.1.8 bin/teamocil