screeninator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.md +87 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/bin/screeninator +7 -0
- data/lib/screeninator.rb +8 -0
- data/lib/screeninator/assets/sample.yml +15 -0
- data/lib/screeninator/assets/screen_config.screen +16 -0
- data/lib/screeninator/cli.rb +119 -0
- data/lib/screeninator/config_writer.rb +64 -0
- data/test/helper.rb +10 -0
- data/test/test_screeninator.rb +7 -0
- metadata +88 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Jon Druse
|
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,87 @@
|
|
1
|
+
Screeninator
|
2
|
+
============
|
3
|
+
|
4
|
+
Create an manage screen sessions easily. Inspired by Arthur Chiu's ([Terminitor](http://github.com/achiu/terminitor))
|
5
|
+
|
6
|
+
Installation
|
7
|
+
------------
|
8
|
+
|
9
|
+
$ gem install screeninator
|
10
|
+
|
11
|
+
Then follow the instructions. You just have to drop a line in your ~/.bashrc file, similar to RVM if you've used that before:
|
12
|
+
|
13
|
+
if [[ -s /Users/jondruse/.screeninator/scripts/screeninator ]] ; then source /Users/jondruse/.screeninator/scripts/screeninator ; fi
|
14
|
+
|
15
|
+
This will load the alias commands into bash.
|
16
|
+
|
17
|
+
Usage
|
18
|
+
-----
|
19
|
+
|
20
|
+
### Create a project ###
|
21
|
+
|
22
|
+
$ screeninator open project_name
|
23
|
+
|
24
|
+
This will open your default editor (set through the $EDITOR variable in BASH) and present you with the default config:
|
25
|
+
|
26
|
+
# ~/.screeninator/project_name.yml
|
27
|
+
# you can make as many tabs as you wish...
|
28
|
+
|
29
|
+
escape: ``
|
30
|
+
project_name: Screeninator
|
31
|
+
project_root: ~/code/rails_project
|
32
|
+
tabs:
|
33
|
+
- shell: git pull
|
34
|
+
- database: rails db
|
35
|
+
- console: rails c
|
36
|
+
- logs:
|
37
|
+
- cd logs
|
38
|
+
- tail -f development.log
|
39
|
+
- ssh: ssh me@myhost
|
40
|
+
|
41
|
+
|
42
|
+
If a tab contains multiple commands, they will be 'joined' together with '&&'.
|
43
|
+
|
44
|
+
|
45
|
+
Starting a project
|
46
|
+
------------------
|
47
|
+
|
48
|
+
$ start_project_name
|
49
|
+
|
50
|
+
This will fire up screen with all the tabs you configured.
|
51
|
+
|
52
|
+
### Limitations ###
|
53
|
+
|
54
|
+
After you create a project, you will have to open a new shell window. This is because Screeninator adds an alias to bash to open screen with the project config.
|
55
|
+
|
56
|
+
|
57
|
+
Other Commands
|
58
|
+
--------------
|
59
|
+
|
60
|
+
$ screeninator list
|
61
|
+
|
62
|
+
List all the projects you have configured
|
63
|
+
|
64
|
+
$ screeninator delete project_name
|
65
|
+
|
66
|
+
Remove a project
|
67
|
+
|
68
|
+
$ screeninator implode
|
69
|
+
|
70
|
+
Remove all screeninator configs, aliases and scripts.
|
71
|
+
|
72
|
+
|
73
|
+
Note on Patches/Pull Requests
|
74
|
+
-----------------------------
|
75
|
+
|
76
|
+
* Fork the project.
|
77
|
+
* Make your feature addition or bug fix.
|
78
|
+
* Add tests for it. This is important so I don't break it in a
|
79
|
+
future version unintentionally.
|
80
|
+
* Commit, do not mess with rakefile, version, or history.
|
81
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
82
|
+
* Send me a pull request. Bonus points for topic branches.
|
83
|
+
|
84
|
+
Copyright
|
85
|
+
---------
|
86
|
+
|
87
|
+
Copyright (c) 2010 Jon Druse. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "screeninator"
|
8
|
+
gem.summary = %Q{Create and manage complex screen sessions easily.}
|
9
|
+
gem.description = %Q{Create and manage complex screen sessions easily.}
|
10
|
+
gem.email = "jon@jondruse.com"
|
11
|
+
gem.homepage = "http://github.com/jondruse/screeninator"
|
12
|
+
gem.authors = ["Jon Druse"]
|
13
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
14
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
|
+
end
|
16
|
+
Jeweler::GemcutterTasks.new
|
17
|
+
rescue LoadError
|
18
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |test|
|
23
|
+
test.libs << 'lib' << 'test'
|
24
|
+
test.pattern = 'test/**/test_*.rb'
|
25
|
+
test.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
require 'rcov/rcovtask'
|
30
|
+
Rcov::RcovTask.new do |test|
|
31
|
+
test.libs << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
task :rcov do
|
37
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
task :test => :check_dependencies
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "screeninator #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/screeninator
ADDED
data/lib/screeninator.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# ~/.screeninator/<%= @name %>.yml
|
2
|
+
# you can make as many tabs as you wish...
|
3
|
+
|
4
|
+
escape: ``
|
5
|
+
project_name: Screeninator
|
6
|
+
project_root: ~/code/rails_project
|
7
|
+
tabs:
|
8
|
+
- shell: git pull
|
9
|
+
- database: rails db
|
10
|
+
- server: rails s
|
11
|
+
- logs: tail -f logs/development.log
|
12
|
+
- console: rails c
|
13
|
+
- capistrano:
|
14
|
+
- server: ssh me@myhost
|
15
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
startup_message off
|
2
|
+
vbell off
|
3
|
+
escape <%= @escape || "``" %>
|
4
|
+
autodetach on
|
5
|
+
defscrollback 10000
|
6
|
+
hardstatus alwayslastline
|
7
|
+
hardstatus string '%{= kg}[ %{G} <%= @project_name %> %{g}][%= %{= kw}%?%-Lw%?%{r} (%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m/%d %{W}%c %{g}]'
|
8
|
+
|
9
|
+
chdir "<%= @project_root %>"
|
10
|
+
|
11
|
+
<% @tabs.each do |tab| %>
|
12
|
+
screen -t <%= tab.name %> <%= @tabs.index(tab) + 1 %>
|
13
|
+
stuff "<%= tab.stuff %>\012"
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
select 1
|
@@ -0,0 +1,119 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
##
|
4
|
+
# Author:: Jon Druse (mailto:jon@jondruse.com)
|
5
|
+
#
|
6
|
+
# = Description
|
7
|
+
#
|
8
|
+
# This class is where each screeninator command is implemented.
|
9
|
+
#
|
10
|
+
# == Change History
|
11
|
+
# 09/20/10:: created Jon Druse (mailto:jon@jondruse.com)
|
12
|
+
###
|
13
|
+
module Screeninator
|
14
|
+
class Cli
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def start(*args)
|
18
|
+
|
19
|
+
if args.empty?
|
20
|
+
self.usage
|
21
|
+
else
|
22
|
+
self.send(args.shift, *args)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
# print the usage string, this is a fall through method.
|
28
|
+
def usage
|
29
|
+
puts "Usage: screeninator ACTION [Arg]"
|
30
|
+
end
|
31
|
+
|
32
|
+
# Open a config file, it's created if it doesn't exist already.
|
33
|
+
def open(*args)
|
34
|
+
puts "warning: passing multiple arguments to open will be ignored" if args.size > 1
|
35
|
+
@name = args.shift
|
36
|
+
FileUtils.mkdir_p(root_dir+"scripts")
|
37
|
+
config_path = "#{root_dir}#{@name}.yml"
|
38
|
+
unless File.exists?(config_path)
|
39
|
+
template = "#{File.dirname(__FILE__)}/assets/sample.yml"
|
40
|
+
erb = ERB.new(File.read(template)).result(binding)
|
41
|
+
tmp = File.open(config_path, 'w') {|f| f.write(erb) }
|
42
|
+
end
|
43
|
+
`$EDITOR #{config_path}`
|
44
|
+
update_scripts
|
45
|
+
end
|
46
|
+
|
47
|
+
def delete(*args)
|
48
|
+
puts "warning: passing multiple arguments to delete will be ignored" if args.size > 1
|
49
|
+
filename = args.shift
|
50
|
+
file_path = "#{root_dir}#{filename}.yml"
|
51
|
+
|
52
|
+
if File.exists?(file_path)
|
53
|
+
puts "Are you sure you want to delete #{filename}? (type yes or no):"
|
54
|
+
if %w(yes Yes YES).include?(STDIN.gets.chop)
|
55
|
+
FileUtils.rm(file_path)
|
56
|
+
puts "Deleted #{file_path}"
|
57
|
+
else
|
58
|
+
puts "Aborting."
|
59
|
+
end
|
60
|
+
else
|
61
|
+
puts "That file doesn't exist."
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
def implode(*args)
|
67
|
+
puts "delete_all doesn't accapt any arguments!" unless args.empty?
|
68
|
+
puts "Are you sure you want to delete all screeninator configs? (type yes or no):"
|
69
|
+
|
70
|
+
if %w(yes Yes YES).include?(STDIN.gets.chop)
|
71
|
+
FileUtils.remove_dir(root_dir)
|
72
|
+
puts "Deleted #{root_dir}"
|
73
|
+
else
|
74
|
+
puts "Aborting."
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
def list(*args)
|
80
|
+
verbose = args.include?("-v")
|
81
|
+
puts "screeninator configs:"
|
82
|
+
Dir["#{root_dir}**"].each do |path|
|
83
|
+
next unless verbose || File.extname(path) == ".yml"
|
84
|
+
path = path.gsub(root_dir, '').gsub('.yml','') unless verbose
|
85
|
+
puts " #{path}"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# def run(*args)
|
90
|
+
# filename = args.shift
|
91
|
+
# puts "Running: #{filename}"
|
92
|
+
# Screeninator::Runner.new(filename).run!
|
93
|
+
# end
|
94
|
+
|
95
|
+
def update_scripts
|
96
|
+
aliases = []
|
97
|
+
Dir["#{root_dir}*.yml"].each do |path|
|
98
|
+
path = File.basename(path, '.yml')
|
99
|
+
aliases << Screeninator::ConfigWriter.new(path).write!
|
100
|
+
end
|
101
|
+
|
102
|
+
Screeninator::ConfigWriter.write_aliases(aliases)
|
103
|
+
end
|
104
|
+
|
105
|
+
private
|
106
|
+
|
107
|
+
def root_dir
|
108
|
+
"#{ENV["HOME"]}/.screeninator/"
|
109
|
+
end
|
110
|
+
|
111
|
+
def sample_config
|
112
|
+
"#{File.dirname(__FILE__)}/assets/sample.yml"
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Screeninator
|
2
|
+
|
3
|
+
class ConfigWriter
|
4
|
+
|
5
|
+
def self.write_aliases(aliases)
|
6
|
+
File.open("#{ENV["HOME"]}/.screeninator/scripts/screeninator", 'w') {|f| f.write(aliases.join("\n")) }
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(filename)
|
10
|
+
@filename = filename
|
11
|
+
@file_path = "#{root_dir}#{@filename}.yml"
|
12
|
+
process_config!
|
13
|
+
end
|
14
|
+
|
15
|
+
def write!
|
16
|
+
template = "#{File.dirname(__FILE__)}/assets/screen_config.screen"
|
17
|
+
erb = ERB.new(IO.read(template)).result(binding)
|
18
|
+
config_path = "#{root_dir}#{@filename}.screen"
|
19
|
+
tmp = File.open(config_path, 'w') {|f| f.write(erb) }
|
20
|
+
|
21
|
+
"alias start_#{@filename}='screen -c #{config_path} -S #{@project_name.gsub(" ", "_")}'"
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def root_dir
|
27
|
+
"#{ENV["HOME"]}/.screeninator/"
|
28
|
+
end
|
29
|
+
|
30
|
+
def process_config!
|
31
|
+
yaml = YAML.load(File.read(@file_path))
|
32
|
+
|
33
|
+
raise "Your configuration file should include some tabs." if yaml["tabs"].nil?
|
34
|
+
puts "Your configuration file didn't specify a 'project_root', using ~/" if yaml["project_root"].nil?
|
35
|
+
if yaml["project_name"].nil?
|
36
|
+
puts "Your configuration file didn't specify a 'project_name', using 'Fluffy Bunnies'"
|
37
|
+
yaml["project_name"] = 'Fluffy Bunnies'
|
38
|
+
end
|
39
|
+
|
40
|
+
@escape = yaml["escape"]
|
41
|
+
@project_name = yaml["project_name"]
|
42
|
+
@project_root = yaml["project_root"]
|
43
|
+
@tabs = []
|
44
|
+
|
45
|
+
yaml["tabs"].each do |tab|
|
46
|
+
t = OpenStruct.new
|
47
|
+
t.name = tab.keys.first
|
48
|
+
value = tab.values.first
|
49
|
+
t.stuff = if value.is_a?(Array)
|
50
|
+
value.join(" && ")
|
51
|
+
else
|
52
|
+
value
|
53
|
+
end
|
54
|
+
@tabs << t
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
def write_alias(stuff)
|
60
|
+
File.open("#{root_dir}scripts/#{@filename}", 'w') {|f| f.write(stuff) }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: screeninator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Jon Druse
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-09-22 00:00:00 -07:00
|
18
|
+
default_executable: screeninator
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: thoughtbot-shoulda
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
32
|
+
description: Create and manage complex screen sessions easily.
|
33
|
+
email: jon@jondruse.com
|
34
|
+
executables:
|
35
|
+
- screeninator
|
36
|
+
extensions: []
|
37
|
+
|
38
|
+
extra_rdoc_files:
|
39
|
+
- LICENSE
|
40
|
+
- README.md
|
41
|
+
files:
|
42
|
+
- .document
|
43
|
+
- .gitignore
|
44
|
+
- LICENSE
|
45
|
+
- README.md
|
46
|
+
- Rakefile
|
47
|
+
- VERSION
|
48
|
+
- bin/screeninator
|
49
|
+
- lib/screeninator.rb
|
50
|
+
- lib/screeninator/assets/sample.yml
|
51
|
+
- lib/screeninator/assets/screen_config.screen
|
52
|
+
- lib/screeninator/cli.rb
|
53
|
+
- lib/screeninator/config_writer.rb
|
54
|
+
- test/helper.rb
|
55
|
+
- test/test_screeninator.rb
|
56
|
+
has_rdoc: true
|
57
|
+
homepage: http://github.com/jondruse/screeninator
|
58
|
+
licenses: []
|
59
|
+
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options:
|
62
|
+
- --charset=UTF-8
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
version: "0"
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
requirements: []
|
80
|
+
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.3.6
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: Create and manage complex screen sessions easily.
|
86
|
+
test_files:
|
87
|
+
- test/helper.rb
|
88
|
+
- test/test_screeninator.rb
|