doitian-tmuxinator 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "http://rubygems.org"
2
+
3
+ group :development do
4
+ gem "rspec", "~> 2.1.0"
5
+ gem "bundler", "~> 1.0.0"
6
+ gem "jeweler", "~> 1.5.1"
7
+ gem "rcov", ">= 0"
8
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,28 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.2)
5
+ git (1.2.5)
6
+ jeweler (1.5.1)
7
+ bundler (~> 1.0.0)
8
+ git (>= 1.2.5)
9
+ rake
10
+ rake (0.8.7)
11
+ rcov (0.9.9)
12
+ rspec (2.1.0)
13
+ rspec-core (~> 2.1.0)
14
+ rspec-expectations (~> 2.1.0)
15
+ rspec-mocks (~> 2.1.0)
16
+ rspec-core (2.1.0)
17
+ rspec-expectations (2.1.0)
18
+ diff-lcs (~> 1.1.2)
19
+ rspec-mocks (2.1.0)
20
+
21
+ PLATFORMS
22
+ ruby
23
+
24
+ DEPENDENCIES
25
+ bundler (~> 1.0.0)
26
+ jeweler (~> 1.5.1)
27
+ rcov
28
+ rspec (~> 2.1.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Allen Bargi
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,171 @@
1
+ # Tmuxinator
2
+
3
+ Create and manage tmux sessions easily. Inspired by Jon Druse's ([Screeninator](https://github.com/jondruse/screeninator)) and Arthur Chiu's ([Terminitor](http://github.com/achiu/terminitor))
4
+
5
+ ## Example
6
+
7
+ ![Sample](http://f.cl.ly/items/3e3I1l1t3D2U472n1h0h/Screen%20shot%202010-12-10%20at%2010.59.17%20PM.png)
8
+
9
+
10
+ ## Installation
11
+
12
+ $ gem install tmuxinator
13
+
14
+ Then follow the instructions. You just have to drop a line in your ~/.bashrc file, similar to RVM if you've used that before:
15
+
16
+ [[ -s $HOME/.tmuxinator/scripts/tmuxinator ]] && source $HOME/.tmuxinator/scripts/tmuxinator
17
+
18
+ ## Editor and Shell
19
+
20
+ tmuxinator uses your shell's default editor for opening files. If you're not sure what that is type:
21
+
22
+ $ echo $EDITOR
23
+
24
+ For me that produces "mate -w"
25
+ If you want to change your default editor simple put a line in ~/.bashrc that changes it. Mine looks like this:
26
+
27
+ export EDITOR='mate -w'
28
+
29
+ It also uses $SHELL variable. which is always set by your shell.
30
+
31
+ ## Usage
32
+
33
+
34
+ ### Create a project ###
35
+
36
+ $ tmuxinator new project_name
37
+
38
+ Create or edit your projects with this command, for editing you can also use `tmuxinator open project_name`. `new` aliased to `o`,`open` and `n`. Your default editor ($EDITOR) is used to open the file. If this is a new project you will see this default config:
39
+
40
+ # ~/.tmuxinator/project_name.yml
41
+ # you can make as many tabs as you wish...
42
+
43
+ project_name: Tmuxinator
44
+ project_root: ~/code/rails_project
45
+ rvm: 1.9.2@rails_project
46
+ pre: sudo /etc/rc.d/mysqld start
47
+ tabs:
48
+ - editor:
49
+ layout: main-vertical
50
+ panes:
51
+ - vim
52
+ - #empty, will just run plain bash
53
+ - top
54
+ - shell: git pull
55
+ - database: rails db
56
+ - server: rails s
57
+ - logs: tail -f logs/development.log
58
+ - console: rails c
59
+ - capistrano:
60
+ - server: ssh me@myhost
61
+
62
+
63
+ If a tab contains multiple commands, they will be 'joined' together with '&&'.
64
+ If you want to have your own default config, place it into $HOME/.tmuxinator/default.yml
65
+
66
+ The `pre` command allows you to run anything before starting the tmux session. Could be handy to make sure you database daemons are running. Multiple commands can be specified, just like for tabs.
67
+
68
+ ## Panes Support
69
+ you can define your own panes inside a window likes this:
70
+
71
+ - window_with_panes
72
+ layout: main-vertical
73
+ panes:
74
+ - vim
75
+ - #empty, will just run plain bash
76
+ - top
77
+
78
+
79
+ ## Starting a project
80
+
81
+ $ start_project_name
82
+
83
+ This will fire up tmux with all the tabs you configured.
84
+
85
+ ### Limitations ###
86
+
87
+ After you create a project, you will have to open a new shell window. This is because tmuxinator adds an
88
+ alias to bash (or any other shell you use, like zsh) to open tmux with the project config. You can reload your shell rc file
89
+ instead of openning a new window like this, for instance in bash you could do this:
90
+
91
+ $ source ~/.bashrc
92
+
93
+ ## Other Commands
94
+
95
+ $ tmuxinator copy existing_project new_project
96
+
97
+ Copy an existing project. aliased to `c`
98
+
99
+
100
+ $ tmuxinator update_scripts
101
+
102
+ Re-create the tmux scripts and aliases from the configs. Use this only if you edit your project configs outside of tmuxinator, i.e. not using "tmuxinator open xxx".
103
+
104
+
105
+ $ tmuxinator list
106
+
107
+ List all the projects you have configured. aliased to `l`
108
+
109
+
110
+ $ tmuxinator delete project_name
111
+
112
+ Remove a project
113
+
114
+
115
+ $ tmuxinator implode
116
+
117
+ Remove all tmuxinator configs, aliases and scripts. aliased to `i`
118
+
119
+ $ tmuxinator doctor
120
+
121
+ Examines your environment and identifies problems with your configuration
122
+
123
+
124
+ $ tmuxinator version
125
+
126
+ shows tmuxinator's version. aliased to `v`
127
+
128
+
129
+ $ tmuxinator help
130
+
131
+ shows tmuxinator's help. aliased to `h`
132
+
133
+ ## Questions? Comments? Feature Request?
134
+
135
+ I would love to hear your feedback on this project! Send me a message!
136
+
137
+ ## Contributors:
138
+
139
+ * [Aaron Spiegel](https://github.com/spiegela)
140
+ * [Jay Adkisson](https://github.com/jayferd)
141
+ * [Chris Lerum](https://github.com/chrislerum)
142
+ * [David Bolton](https://github.com/lightningdb)
143
+ * [Thibault Duplessis](https://github.com/ornicar)
144
+ * [Ian Yang](https://github.com/doitian)
145
+ * [Bjørn Arild Mæland](https://github.com/bmaland)
146
+
147
+
148
+ ## History
149
+ ###v. 0.3.0
150
+ * added pre command (Thanks to Ian Yang)
151
+ * added multiple pre command (Thanks to Bjørn Arild Mæland)
152
+ * using tmux set default-path for project root
153
+ * new aliases
154
+
155
+ ###v. 0.2.0
156
+ * added pane support (Thanks to Aaron Spiegel)
157
+ * RVM support (Thanks to Jay Adkisoon)
158
+
159
+ ## Contributing to tmuxinator
160
+
161
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
162
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
163
+ * Fork the project
164
+ * Start a feature/bugfix branch
165
+ * Commit and push until you are happy with your contribution
166
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
167
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
168
+
169
+ ## Copyright
170
+
171
+ Copyright (c) 2010 Allen Bargi. See LICENSE.txt for further details.
data/Rakefile ADDED
@@ -0,0 +1,72 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "doitian-tmuxinator"
16
+ gem.homepage = "http://github.com/aziz/tmuxinator"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Create and manage complex tmux sessions easily.}
19
+ gem.description = %Q{Create and manage complex tmux sessions easily.}
20
+ gem.email = "allen.bargi@gmail.com"
21
+ gem.authors = ["Allen Bargi"]
22
+ gem.post_install_message = %{
23
+ __________________________________________________________
24
+ ..........................................................
25
+
26
+ Thank you for installing tmuxinator
27
+ Please be sure to to drop a line in your ~/.bashrc file, similar
28
+ to RVM if you've used that before:
29
+
30
+ [[ -s $HOME/.tmuxinator/scripts/tmuxinator ]] && source $HOME/.tmuxinator/scripts/tmuxinator
31
+
32
+ also ensure that you've set these variables in your ENV:
33
+
34
+ $EDITOR, $SHELL
35
+
36
+ you can run `tmuxinator doctor` to make sure everything is set.
37
+ happy tmuxing with tmuxinator!
38
+
39
+ ..........................................................
40
+ __________________________________________________________
41
+
42
+ }
43
+
44
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
45
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
46
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
47
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
48
+ end
49
+ Jeweler::RubygemsDotOrgTasks.new
50
+
51
+ require 'rspec/core'
52
+ require 'rspec/core/rake_task'
53
+ RSpec::Core::RakeTask.new(:spec) do |spec|
54
+ spec.pattern = FileList['spec/**/*_spec.rb']
55
+ end
56
+
57
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
58
+ spec.pattern = 'spec/**/*_spec.rb'
59
+ spec.rcov = true
60
+ end
61
+
62
+ task :default => :spec
63
+
64
+ require 'rake/rdoctask'
65
+ Rake::RDocTask.new do |rdoc|
66
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
67
+
68
+ rdoc.rdoc_dir = 'rdoc'
69
+ rdoc.title = "tmuxinator #{version}"
70
+ rdoc.rdoc_files.include('README*')
71
+ rdoc.rdoc_files.include('lib/**/*.rb')
72
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.3
data/bin/tmuxinator ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')
3
+
4
+ require 'tmuxinator'
5
+
6
+ Tmuxinator::Cli.start(*ARGV)
@@ -0,0 +1,94 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{doitian-tmuxinator}
8
+ s.version = "0.3.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Allen Bargi"]
12
+ s.date = %q{2011-06-21}
13
+ s.default_executable = %q{tmuxinator}
14
+ s.description = %q{Create and manage complex tmux sessions easily.}
15
+ s.email = %q{allen.bargi@gmail.com}
16
+ s.executables = ["tmuxinator"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE.txt",
27
+ "README.md",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "bin/tmuxinator",
31
+ "doitian-tmuxinator.gemspec",
32
+ "lib/tmuxinator.rb",
33
+ "lib/tmuxinator/assets/sample.yml",
34
+ "lib/tmuxinator/assets/tmux_config.tmux",
35
+ "lib/tmuxinator/cli.rb",
36
+ "lib/tmuxinator/config_writer.rb",
37
+ "lib/tmuxinator/helper.rb",
38
+ "spec/spec_helper.rb",
39
+ "spec/tmuxinator_spec.rb",
40
+ "tmuxinator.gemspec"
41
+ ]
42
+ s.homepage = %q{http://github.com/aziz/tmuxinator}
43
+ s.licenses = ["MIT"]
44
+ s.post_install_message = %q{
45
+ __________________________________________________________
46
+ ..........................................................
47
+
48
+ Thank you for installing tmuxinator
49
+ Please be sure to to drop a line in your ~/.bashrc file, similar
50
+ to RVM if you've used that before:
51
+
52
+ [[ -s $HOME/.tmuxinator/scripts/tmuxinator ]] && source $HOME/.tmuxinator/scripts/tmuxinator
53
+
54
+ also ensure that you've set these variables in your ENV:
55
+
56
+ $EDITOR, $SHELL
57
+
58
+ you can run `tmuxinator doctor` to make sure everything is set.
59
+ happy tmuxing with tmuxinator!
60
+
61
+ ..........................................................
62
+ __________________________________________________________
63
+
64
+ }
65
+ s.require_paths = ["lib"]
66
+ s.rubygems_version = %q{1.5.2}
67
+ s.summary = %q{Create and manage complex tmux sessions easily.}
68
+ s.test_files = [
69
+ "spec/spec_helper.rb",
70
+ "spec/tmuxinator_spec.rb"
71
+ ]
72
+
73
+ if s.respond_to? :specification_version then
74
+ s.specification_version = 3
75
+
76
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
77
+ s.add_development_dependency(%q<rspec>, ["~> 2.1.0"])
78
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
79
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
80
+ s.add_development_dependency(%q<rcov>, [">= 0"])
81
+ else
82
+ s.add_dependency(%q<rspec>, ["~> 2.1.0"])
83
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
84
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
85
+ s.add_dependency(%q<rcov>, [">= 0"])
86
+ end
87
+ else
88
+ s.add_dependency(%q<rspec>, ["~> 2.1.0"])
89
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
90
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
91
+ s.add_dependency(%q<rcov>, [">= 0"])
92
+ end
93
+ end
94
+
data/lib/tmuxinator.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'yaml'
2
+ require 'ostruct'
3
+ require 'erb'
4
+ require 'tmuxinator/helper'
5
+ require 'tmuxinator/cli'
6
+ require 'tmuxinator/config_writer'
7
+
8
+ TMUX_TEMPLATE = "#{File.dirname(__FILE__)}/tmuxinator/assets/tmux_config.tmux"
9
+
10
+ module Tmuxinator
11
+ end
@@ -0,0 +1,21 @@
1
+ # ~/.tmuxinator/<%= @name %>.yml
2
+ # you can make as many tabs as you wish...
3
+
4
+ project_name: Tmuxinator
5
+ project_root: ~/code/rails_project
6
+ rvm: 1.9.2@rails_project
7
+ pre: sudo /etc/rc.d/mysqld start
8
+ tabs:
9
+ - editor:
10
+ layout: main-vertical
11
+ panes:
12
+ - vim
13
+ - #empty, will just run plain bash
14
+ - top
15
+ - shell: git pull
16
+ - database: rails db
17
+ - server: rails s
18
+ - logs: tail -f logs/development.log
19
+ - console: rails c
20
+ - capistrano:
21
+ - server: ssh me@myhost
@@ -0,0 +1,37 @@
1
+ #!<%= ENV['SHELL'] || '/bin/bash' %>
2
+ tmux start-server
3
+
4
+ if ! $(tmux has-session -t <%=s @project_name %>); then
5
+ cd <%= @project_root || "." %>
6
+ <%= @pre %>
7
+ env TMUX= tmux start-server \; set-option -g base-index 1 \; new-session -d -s <%=s @project_name %> -n <%=s @tabs[0].name %>
8
+ tmux set-option -t <%=s @project_name %> default-path <%= @project_root %>
9
+
10
+ <% @tabs[1..-1].each_with_index do |tab, i| %>
11
+ tmux new-window -t <%= window(i+2) %> -n <%=s tab.name %>
12
+ <% end %>
13
+
14
+ # set up tabs and panes
15
+ <% @tabs.each_with_index do |tab, i| %>
16
+ # tab "<%= tab.name %>"
17
+ <% if tab.command %>
18
+ <%= send_keys(tab.command, i+1) %>
19
+ <% elsif tab.panes %>
20
+ <%= send_keys(tab.panes.shift, i+1) %>
21
+ <% tab.panes.each do |pane| %>
22
+ tmux splitw -t <%= window(i+1) %>
23
+ <%= send_keys(pane, i+1) %>
24
+ <% end %>
25
+ tmux select-layout -t <%= window(i+1) %> <%=s tab.layout %>
26
+ <% end %>
27
+ <% end %>
28
+
29
+ tmux select-window -t <%= window(1) %>
30
+
31
+ fi
32
+
33
+ if [ -z $TMUX ]; then
34
+ tmux -u attach-session -t <%=s @project_name %>
35
+ else
36
+ tmux -u switch-client -t <%=s @project_name %>
37
+ fi
@@ -0,0 +1,176 @@
1
+ require 'fileutils'
2
+
3
+ module Tmuxinator
4
+ class Cli
5
+
6
+ class << self
7
+ include Tmuxinator::Helper
8
+
9
+ def start *args
10
+ if args.empty?
11
+ self.usage
12
+ else
13
+ self.send(args.shift, *args)
14
+ end
15
+ end
16
+
17
+ # print the usage string, this is a fall through method.
18
+ def usage
19
+ puts %{
20
+ Usage: tmuxinator ACTION [Arg]
21
+
22
+ ACTIONS:
23
+ open [project_name]
24
+ create a new project file and open it in your editor
25
+ copy [source_project] [new_project]
26
+ copy source_project project file to a new project called new_project
27
+ delete [project_name]
28
+ deletes the project called project_name
29
+ update_scripts
30
+ re-create the tmux scripts and aliases from the configs
31
+ implode
32
+ deletes all existing projects!
33
+ list [-v]
34
+ list all existing projects
35
+ doctor
36
+ look for problems in your configuration
37
+ help
38
+ shows this help document
39
+ version
40
+
41
+ }
42
+ end
43
+ alias :help :usage
44
+ alias :h :usage
45
+
46
+ # Open a config file, it's created if it doesn't exist already.
47
+ def open *args
48
+ exit!("You must specify a name for the new project") unless args.size > 0
49
+ puts "warning: passing multiple arguments to open will be ignored" if args.size > 1
50
+ @name = args.shift
51
+ FileUtils.mkdir_p(root_dir+"scripts")
52
+ config_path = "#{root_dir}#{@name}.yml"
53
+ unless File.exists?(config_path)
54
+ template = File.exists?(user_config) ? user_config : "#{File.dirname(__FILE__)}/assets/sample.yml"
55
+ erb = ERB.new(File.read(template)).result(binding)
56
+ tmp = File.open(config_path, 'w') {|f| f.write(erb) }
57
+ end
58
+ system("$EDITOR #{config_path}")
59
+ update_scripts
60
+ end
61
+ alias :o :open
62
+ alias :new :open
63
+ alias :n :open
64
+
65
+ def copy *args
66
+ @copy = args.shift
67
+ @name = args.shift
68
+ @config_to_copy = "#{root_dir}#{@copy}.yml"
69
+
70
+ exit!("Project #{@copy} doesn't exist!") unless File.exists?(@config_to_copy)
71
+ exit!("You must specify a name for the new project") unless @name
72
+
73
+ file_path = "#{root_dir}#{@name}.yml"
74
+
75
+ if File.exists?(file_path)
76
+ confirm!("#{@name} already exists, would you like to overwrite it? (type yes or no):") do
77
+ FileUtils.rm(file_path)
78
+ puts "Overwriting #{@name}"
79
+ end
80
+ end
81
+ open @name
82
+ end
83
+ alias :c :copy
84
+
85
+ def delete *args
86
+ puts "warning: passing multiple arguments to delete will be ignored" if args.size > 1
87
+ filename = args.shift
88
+ file_path = "#{root_dir}#{filename}.yml"
89
+
90
+ if File.exists?(file_path)
91
+ confirm!("Are you sure you want to delete #{filename}? (type yes or no):") do
92
+ FileUtils.rm(file_path)
93
+ puts "Deleted #{filename}"
94
+ end
95
+ else
96
+ exit! "That file doesn't exist."
97
+ end
98
+ end
99
+ alias :d :delete
100
+
101
+ def implode *args
102
+ exit!("delete_all doesn't accapt any arguments!") unless args.empty?
103
+ confirm!("Are you sure you want to delete all tmuxinator configs? (type yes or no):") do
104
+ FileUtils.remove_dir(root_dir)
105
+ puts "Deleted #{root_dir}"
106
+ end
107
+ end
108
+ alias :i :implode
109
+
110
+ def list *args
111
+ verbose = args.include?("-v")
112
+ puts "tmuxinator configs:"
113
+ Dir["#{root_dir}**"].each do |path|
114
+ next unless verbose || File.extname(path) == ".yml"
115
+ path = path.gsub(root_dir, '').gsub('.yml','') unless verbose
116
+ puts " #{path}"
117
+ end
118
+ end
119
+ alias :l :list
120
+ alias :ls :list
121
+
122
+ def version
123
+ system("cat #{File.dirname(__FILE__) + '/../../VERSION'}")
124
+ puts
125
+ end
126
+ alias :v :version
127
+
128
+ def update_scripts
129
+ Dir["#{root_dir}*.tmux"].each {|p| FileUtils.rm(p) }
130
+ aliases = []
131
+ Dir["#{root_dir}*.yml"].each do |path|
132
+ aliases << Tmuxinator::ConfigWriter.new(path).write!
133
+ end
134
+ Tmuxinator::ConfigWriter.write_aliases(aliases)
135
+ end
136
+
137
+ def doctor
138
+ print " cheking if tmux is installed ==> "
139
+ puts system("which tmux > /dev/null") ? "Yes" : "No"
140
+ print " cheking if $EDITOR is set ==> "
141
+ puts ENV['EDITOR'] ? "Yes" : "No"
142
+ print " cheking if $SHELL is set ==> "
143
+ puts ENV['SHELL'] ? "Yes" : "No"
144
+ puts %{
145
+ make sure you have this line in your ~/.bashrc file:
146
+
147
+ [[ -s $HOME/.tmuxinator/scripts/tmuxinator ]] && source $HOME/.tmuxinator/scripts/tmuxinator
148
+
149
+
150
+ }
151
+ end
152
+
153
+ def method_missing method, *args, &block
154
+ puts "There's no command called #{method} in tmuxinator"
155
+ usage
156
+ end
157
+
158
+ private #==============================
159
+
160
+ def root_dir
161
+ "#{ENV["HOME"]}/.tmuxinator/"
162
+ end
163
+
164
+ def sample_config
165
+ "#{File.dirname(__FILE__)}/assets/sample.yml"
166
+ end
167
+
168
+ def user_config
169
+ @config_to_copy || "#{ENV["HOME"]}/.tmuxinator/default.yml"
170
+ end
171
+
172
+ end
173
+
174
+ end
175
+ end
176
+
@@ -0,0 +1,102 @@
1
+ module Tmuxinator
2
+
3
+ class ConfigWriter
4
+ attr_accessor :file_name, :file_path, :project_name, :project_root, :rvm, :tabs, :pre
5
+
6
+ include Tmuxinator::Helper
7
+
8
+ def self.write_aliases aliases
9
+ File.open("#{ENV["HOME"]}/.tmuxinator/scripts/tmuxinator", 'w') {|f| f.write(aliases.join("\n")) }
10
+ end
11
+
12
+ def initialize this_full_path=nil
13
+ self.file_path = this_full_path if this_full_path
14
+ end
15
+
16
+ def file_path= full_path
17
+ @file_path = full_path
18
+ @file_name = File.basename full_path, '.yml'
19
+ process_config! if full_path && File.exist?(full_path)
20
+ end
21
+
22
+ def write!
23
+ raise "Unable to write with out a file_name defined" unless self.file_name
24
+ erb = ERB.new(IO.read(TMUX_TEMPLATE)).result(binding)
25
+ tmp = File.open(config_path, 'w') {|f| f.write(erb) }
26
+
27
+ "alias start_#{file_name}='$SHELL #{config_path}'"
28
+ end
29
+
30
+ def config_path
31
+ "#{root_dir}#{file_name}.tmux" if file_name
32
+ end
33
+
34
+ private
35
+
36
+ def root_dir
37
+ "#{ENV["HOME"]}/.tmuxinator/"
38
+ end
39
+
40
+ def process_config!
41
+ yaml = YAML.load(File.read(file_path))
42
+
43
+ exit!("Your configuration file should include some tabs.") if yaml["tabs"].nil?
44
+ exit!("Your configuration file didn't specify a 'project_root'") if yaml["project_root"].nil?
45
+ exit!("Your configuration file didn't specify a 'project_name'") if yaml["project_name"].nil?
46
+
47
+ @project_name = yaml["project_name"]
48
+ @project_root = yaml["project_root"]
49
+ @rvm = yaml["rvm"]
50
+ @pre = build_command(yaml["pre"])
51
+ @tabs = []
52
+
53
+ yaml["tabs"].each do |tab|
54
+ t = OpenStruct.new
55
+ t.name = tab.keys.first
56
+ value = tab.values.first
57
+
58
+ case value
59
+ when Hash
60
+ t.panes = (value["panes"] || ['']).map do |pane|
61
+ build_command(pane)
62
+ end
63
+ t.layout = value["layout"]
64
+ else
65
+ t.command = build_command(value)
66
+ end
67
+ @tabs << t
68
+ end
69
+ end
70
+
71
+ def parse_tabs tab_list
72
+ end
73
+
74
+ def write_alias stuff
75
+ File.open("#{root_dir}scripts/#{@filename}", 'w') {|f| f.write(stuff) }
76
+ end
77
+
78
+ def shell_escape str
79
+ "'#{str.to_s.gsub("'") { %('\'') }}'"
80
+ end
81
+ alias s shell_escape
82
+
83
+ def window(i)
84
+ "#{s @project_name}:#{i}"
85
+ end
86
+
87
+ def send_keys cmd, window_number
88
+ return '' unless cmd
89
+ "tmux send-keys -t #{window(window_number)} #{s cmd} C-m"
90
+ end
91
+
92
+ def build_command(value)
93
+ commands = [value].flatten.compact.reject { |c| c.strip.empty? }
94
+ if @rvm
95
+ commands.unshift "rvm use #{@rvm}"
96
+ end
97
+
98
+ commands.join ' && '
99
+ end
100
+ end
101
+
102
+ end
@@ -0,0 +1,19 @@
1
+ module Tmuxinator
2
+ module Helper
3
+
4
+ def exit!(msg)
5
+ puts msg
6
+ Kernel.exit(1)
7
+ end
8
+
9
+ def confirm!(msg)
10
+ puts msg
11
+ if %w(yes Yes YES y).include?(STDIN.gets.chop)
12
+ yield
13
+ else
14
+ exit! "Aborting."
15
+ end
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'tmuxinator'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ SAMPLE_CONFIG = File.join(File.dirname(__FILE__), '..', 'lib', 'tmuxinator', 'assets', 'sample.yml')
11
+
12
+ RSpec.configure do |config|
13
+
14
+ end
@@ -0,0 +1,52 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Tmuxinator::ConfigWriter do
4
+ context "With no defined filename" do
5
+ its(:file_path){ should be_nil }
6
+ its(:project_name){ should be_nil }
7
+ its(:project_root){ should be_nil }
8
+ its(:rvm){ should be_nil }
9
+ its(:tabs){ should be_nil }
10
+ its(:config_path){ should be_nil }
11
+ its(:pre){ should be_nil }
12
+ end
13
+
14
+ context "While Defining the filename on init" do
15
+ subject{ Tmuxinator::ConfigWriter.new(SAMPLE_CONFIG) }
16
+ its(:file_path){ should eql SAMPLE_CONFIG }
17
+ its(:file_name){ should eql "sample" }
18
+ end
19
+
20
+ context "After filename has been defined" do
21
+ before do
22
+ subject.file_path = SAMPLE_CONFIG
23
+ end
24
+
25
+ its(:file_path){ should eql SAMPLE_CONFIG }
26
+ its(:file_name){ should eql File.basename(SAMPLE_CONFIG, '.yml')}
27
+ its(:project_name){ should eql 'Tmuxinator' }
28
+ its(:project_root){ should eql '~/code/rails_project' }
29
+ its(:rvm){ should eql '1.9.2@rails_project' }
30
+ its(:tabs){ should be_an Array }
31
+ its(:pre){ should eql 'sudo /etc/rc.d/mysqld start' }
32
+
33
+ let(:first_tab){ subject.tabs[0] }
34
+
35
+ specify{ first_tab.should be_an OpenStruct }
36
+ specify{ first_tab.name.should eql "editor" }
37
+ specify{ first_tab.layout.should eql "main-vertical" }
38
+ specify{ first_tab.panes.should be_an Array }
39
+
40
+ it "should prepend each pane with the rvm string" do
41
+ first_tab.panes.map{|p| p.split(/ && /)[0] }.should eql ["rvm use 1.9.2@rails_project"] * 3
42
+ end
43
+
44
+ it "should append each pane with the command string" do
45
+ first_tab.panes.map{|p| p.split(/ && /)[1] }.should eql ["vim", nil, "top"]
46
+ end
47
+
48
+ let(:second_tab){ subject.tabs[1] }
49
+ specify{ second_tab.name.should eql "shell" }
50
+ specify{ second_tab.command.should eql "rvm use 1.9.2@rails_project && git pull"}
51
+ end
52
+ end
@@ -0,0 +1,94 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{tmuxinator}
8
+ s.version = "0.3.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Allen Bargi"]
12
+ s.date = %q{2011-05-24}
13
+ s.default_executable = %q{tmuxinator}
14
+ s.description = %q{Create and manage complex tmux sessions easily.}
15
+ s.email = %q{allen.bargi@gmail.com}
16
+ s.executables = ["tmuxinator"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.md",
20
+ "TODO"
21
+ ]
22
+ s.files = [
23
+ ".document",
24
+ ".rspec",
25
+ "Gemfile",
26
+ "Gemfile.lock",
27
+ "LICENSE.txt",
28
+ "README.md",
29
+ "Rakefile",
30
+ "VERSION",
31
+ "bin/tmuxinator",
32
+ "lib/tmuxinator.rb",
33
+ "lib/tmuxinator/assets/sample.yml",
34
+ "lib/tmuxinator/assets/tmux_config.tmux",
35
+ "lib/tmuxinator/cli.rb",
36
+ "lib/tmuxinator/config_writer.rb",
37
+ "lib/tmuxinator/helper.rb",
38
+ "spec/spec_helper.rb",
39
+ "spec/tmuxinator_spec.rb",
40
+ "tmuxinator.gemspec"
41
+ ]
42
+ s.homepage = %q{http://github.com/aziz/tmuxinator}
43
+ s.licenses = ["MIT"]
44
+ s.post_install_message = %q{
45
+ __________________________________________________________
46
+ ..........................................................
47
+
48
+ Thank you for installing tmuxinator
49
+ Please be sure to drop a line in your ~/.bashrc file, similar
50
+ to RVM if you've used that before:
51
+
52
+ [[ -s $HOME/.tmuxinator/scripts/tmuxinator ]] && source $HOME/.tmuxinator/scripts/tmuxinator
53
+
54
+ also ensure that you've set these variables in your ENV:
55
+
56
+ $EDITOR, $SHELL
57
+
58
+ you can run `tmuxinator doctor` to make sure everything is set.
59
+ happy tmuxing with tmuxinator!
60
+
61
+ ..........................................................
62
+ __________________________________________________________
63
+
64
+ }
65
+ s.require_paths = ["lib"]
66
+ s.rubygems_version = %q{1.6.2}
67
+ s.summary = %q{Create and manage complex tmux sessions easily.}
68
+ s.test_files = [
69
+ "spec/spec_helper.rb",
70
+ "spec/tmuxinator_spec.rb"
71
+ ]
72
+
73
+ if s.respond_to? :specification_version then
74
+ s.specification_version = 3
75
+
76
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
77
+ s.add_development_dependency(%q<rspec>, ["~> 2.1.0"])
78
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
79
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
80
+ s.add_development_dependency(%q<rcov>, [">= 0"])
81
+ else
82
+ s.add_dependency(%q<rspec>, ["~> 2.1.0"])
83
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
84
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
85
+ s.add_dependency(%q<rcov>, [">= 0"])
86
+ end
87
+ else
88
+ s.add_dependency(%q<rspec>, ["~> 2.1.0"])
89
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
90
+ s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
91
+ s.add_dependency(%q<rcov>, [">= 0"])
92
+ end
93
+ end
94
+
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: doitian-tmuxinator
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.3.3
6
+ platform: ruby
7
+ authors:
8
+ - Allen Bargi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-06-21 00:00:00 +08:00
14
+ default_executable: tmuxinator
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rspec
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 2.1.0
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 1.0.0
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: jeweler
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.5.1
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: rcov
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ description: Create and manage complex tmux sessions easily.
61
+ email: allen.bargi@gmail.com
62
+ executables:
63
+ - tmuxinator
64
+ extensions: []
65
+
66
+ extra_rdoc_files:
67
+ - LICENSE.txt
68
+ - README.md
69
+ files:
70
+ - .document
71
+ - .rspec
72
+ - Gemfile
73
+ - Gemfile.lock
74
+ - LICENSE.txt
75
+ - README.md
76
+ - Rakefile
77
+ - VERSION
78
+ - bin/tmuxinator
79
+ - doitian-tmuxinator.gemspec
80
+ - lib/tmuxinator.rb
81
+ - lib/tmuxinator/assets/sample.yml
82
+ - lib/tmuxinator/assets/tmux_config.tmux
83
+ - lib/tmuxinator/cli.rb
84
+ - lib/tmuxinator/config_writer.rb
85
+ - lib/tmuxinator/helper.rb
86
+ - spec/spec_helper.rb
87
+ - spec/tmuxinator_spec.rb
88
+ - tmuxinator.gemspec
89
+ has_rdoc: true
90
+ homepage: http://github.com/aziz/tmuxinator
91
+ licenses:
92
+ - MIT
93
+ post_install_message: "\n __________________________________________________________\n ..........................................................\n\n Thank you for installing tmuxinator\n Please be sure to to drop a line in your ~/.bashrc file, similar \n to RVM if you've used that before:\n\n [[ -s $HOME/.tmuxinator/scripts/tmuxinator ]] && source $HOME/.tmuxinator/scripts/tmuxinator\n \n also ensure that you've set these variables in your ENV:\n \n $EDITOR, $SHELL\n \n you can run `tmuxinator doctor` to make sure everything is set.\n happy tmuxing with tmuxinator!\n\n ..........................................................\n __________________________________________________________\n \n "
94
+ rdoc_options: []
95
+
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ hash: 3921463994528927364
104
+ segments:
105
+ - 0
106
+ version: "0"
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: "0"
113
+ requirements: []
114
+
115
+ rubyforge_project:
116
+ rubygems_version: 1.5.2
117
+ signing_key:
118
+ specification_version: 3
119
+ summary: Create and manage complex tmux sessions easily.
120
+ test_files:
121
+ - spec/spec_helper.rb
122
+ - spec/tmuxinator_spec.rb