termrc 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -12
- data/Termfile.test +11 -0
- data/lib/template/{termrc_base.template → termfile.template} +0 -0
- data/lib/template/{termrc_with_tabs.template → termfile_with_tabs.template} +0 -0
- data/lib/termrc/builder.rb +14 -11
- data/lib/termrc/cli.rb +35 -23
- data/termrc.gemspec +2 -2
- metadata +8 -8
- data/.termrc +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fcb14299cfde27760c6dfa122bda333155246e1
|
4
|
+
data.tar.gz: e453a10c68003872229394eaef5d654dc37f259e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 688a2d7b691bdff513ac81b37fd7e7bc2a31530cffe8e172f0a836df2e1e939110b09d58809447bfaea21ba3202c6725dd5be1d56b77eca4f66c0314b5931b74
|
7
|
+
data.tar.gz: ab8cfa03d40e366e8570ff25c49dc965e63c4b5dbf28f32c0b20b59eb2e6a7e4eea41b11987addae0766d42e035b0baeff12c374ca04b362dc28e9e3aebe8259
|
data/README.md
CHANGED
@@ -4,23 +4,24 @@ Take your [iTerm2](http://www.iterm2.com/) environments with you wherever you go
|
|
4
4
|
|
5
5
|
Description
|
6
6
|
-----------
|
7
|
-
Termrc allows you to store information about your project's environment for a given project in a small YAML file called a
|
7
|
+
Termrc allows you to store information about your project's environment for a given project in a small YAML file called a `Termfile` file. Restoring your project's environment is as simple as calling `termrc start`. Enjoy.
|
8
8
|
|
9
9
|
Quick Start
|
10
10
|
-----------
|
11
11
|
```bash
|
12
12
|
$ gem install termrc
|
13
|
-
$ termrc create
|
13
|
+
$ termrc create
|
14
14
|
$ termrc start
|
15
15
|
```
|
16
16
|
|
17
17
|
.termrc file
|
18
18
|
----------
|
19
|
-
The
|
19
|
+
The `Termfile` file is a [YAML](http://en.wikipedia.org/wiki/YAML) file which stores information about your project's environment. An environment, in this context, is an iTerm2 window with various panes, each with a different default command that is run when the pane opens. The `layout` dictates what your window looks like, while `commands` gives you a set of commands you can call for each pane.
|
20
20
|
|
21
|
-
Place the
|
21
|
+
Place the `Termfile` file at your project's root, then call `termrc start`. Voila!
|
22
|
+
|
23
|
+
**Example Termfile**
|
22
24
|
|
23
|
-
**Example .termrc**
|
24
25
|
```yaml
|
25
26
|
commands:
|
26
27
|
here: echo "Hello, here."
|
@@ -33,24 +34,26 @@ layout:
|
|
33
34
|
- [ here, there ] # row 1, with 2 panes
|
34
35
|
- [ world ] # row 2, with 1 pane
|
35
36
|
- [ me, you ] # row 3, with 2 panes
|
36
|
-
```
|
37
|
+
```
|
37
38
|
|
38
39
|
**The Result**
|
39
|
-
|
40
|
+
|
41
|
+
A `Termfile` file is a YAML file which requires two keys: `commands` and a `layout`. Each item in `layout` corresponds to a row of panes in iTerm2. So, for instance, the example `Termfile` file above would produce a new iTerm2 window with the following commands running inside each pane:
|
40
42
|
|
41
43
|
<img src="https://rawgithub.com/briangonzalez/termrc/master/images/termrc-screen.png">
|
42
44
|
|
43
|
-
You can supply an optional third key, `root`, which indicates the root directory you'd like each command to be run inside of. Have a look at [this project's](https://github.com/briangonzalez/termrc/blob/master
|
45
|
+
You can supply an optional third key, `root`, which indicates the root directory you'd like each command to be run inside of. Have a look at [this project's](https://github.com/briangonzalez/termrc/blob/master/Termfile.test)`Termfile` file for an example.
|
44
46
|
|
45
|
-
**
|
46
|
-
|
47
|
+
**Tabs**
|
48
|
+
|
49
|
+
You can automate tabs by providing an array of arrays, each array denoting a new tab and the layout within it. See [this template file](https://github.com/briangonzalez/termrc/blob/master/lib/template/termrc_with_tabs.template) for an example.
|
47
50
|
|
48
51
|
CLI
|
49
52
|
---
|
50
53
|
|
51
54
|
```bash
|
52
55
|
$ termrc start # Start termrc file (Shortcut: s, Argument 0: file (optional) )
|
53
|
-
$ termrc create # Create termrc file
|
56
|
+
$ termrc create # Create termrc file
|
54
57
|
$ termrc list # List termrc files in folder (Shortcut: l, Argument 0: folder (optional))
|
55
58
|
```
|
56
59
|
|
@@ -61,7 +64,13 @@ Released under the MIT License.
|
|
61
64
|
|
62
65
|
Questions?
|
63
66
|
----------
|
64
|
-
|
67
|
+
| ![twitter/brianmgonzalez](http://gravatar.com/avatar/f6363fe1d9aadb1c3f07ba7867f0e854?s=70](http://twitter.com/brianmgonzalez "Follow @brianmgonzalez on Twitter") |
|
68
|
+
|---|
|
69
|
+
| [Brian Gonzalez](http://briangonzalez.org) |
|
70
|
+
|
71
|
+
Changelog
|
72
|
+
---------
|
73
|
+
* March 19, 2014 - Now using `Termfile`; panes now named with given command
|
65
74
|
|
66
75
|
Resources
|
67
76
|
---------
|
data/Termfile.test
ADDED
File without changes
|
File without changes
|
data/lib/termrc/builder.rb
CHANGED
@@ -30,7 +30,7 @@ module Termrc
|
|
30
30
|
def applescript_files
|
31
31
|
if tabs?
|
32
32
|
return @layout.each_with_index.map{ |layout_array, index|
|
33
|
-
applescript_file(layout_array, index)
|
33
|
+
applescript_file(layout_array, index)
|
34
34
|
}
|
35
35
|
else
|
36
36
|
return [ applescript_file(@layout, 0) ]
|
@@ -39,16 +39,16 @@ module Termrc
|
|
39
39
|
|
40
40
|
def applescript_file(layout_array, index)
|
41
41
|
t = TEMPLATE
|
42
|
-
|
42
|
+
|
43
43
|
if index > 0
|
44
44
|
# All other tabs.
|
45
45
|
t = t.gsub("[window_or_tab]", new_tab)
|
46
|
-
t = t.gsub("[session]", current_session)
|
46
|
+
t = t.gsub("[session]", current_session)
|
47
47
|
t = t.gsub("[terminate_unused]", terminate_session('last'))
|
48
48
|
else
|
49
49
|
# First tab.
|
50
50
|
t = t.gsub("[window_or_tab]", new_window)
|
51
|
-
t = t.gsub("[session]", new_session)
|
51
|
+
t = t.gsub("[session]", new_session)
|
52
52
|
t = t.gsub("[terminate_unused]", terminate_session)
|
53
53
|
end
|
54
54
|
|
@@ -70,7 +70,7 @@ module Termrc
|
|
70
70
|
def panes(layout_array)
|
71
71
|
cmd = next_pane # back to the top
|
72
72
|
cmd = next_pane # back to the top
|
73
|
-
|
73
|
+
|
74
74
|
layout_array.each do |cmds|
|
75
75
|
cmd << Array.new( cmds.length - 1, new_column ).join("\n")
|
76
76
|
cmd << next_pane
|
@@ -85,10 +85,10 @@ module Termrc
|
|
85
85
|
|
86
86
|
layout_array.each do |commands|
|
87
87
|
commands.each do |name|
|
88
|
-
cmd << execute_command( @cmd_index, @commands[name] )
|
88
|
+
cmd << execute_command( @cmd_index, @commands[name], name )
|
89
89
|
@cmd_index += 1
|
90
90
|
end
|
91
|
-
end
|
91
|
+
end
|
92
92
|
|
93
93
|
cmd
|
94
94
|
end
|
@@ -131,22 +131,25 @@ module Termrc
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def new_session
|
134
|
-
"set mysession to (make new session at the end of sessions)
|
134
|
+
"set mysession to (make new session at the end of sessions)"
|
135
135
|
end
|
136
136
|
|
137
137
|
def current_session
|
138
|
-
"set mysession to (current session)
|
138
|
+
"set mysession to (current session)"
|
139
139
|
end
|
140
140
|
|
141
141
|
def terminate_session(which='first')
|
142
142
|
"terminate the #{which} session"
|
143
143
|
end
|
144
144
|
|
145
|
-
def execute_command(item, command)
|
145
|
+
def execute_command(item, command, name)
|
146
146
|
command = command.gsub('"', '\\"')
|
147
147
|
command = command.gsub("'", "\\'")
|
148
148
|
command = "cd #{@root} && " + command if @root
|
149
|
-
|
149
|
+
<<-EOH
|
150
|
+
tell item #{item} of sessions to set name to "#{name}" \n
|
151
|
+
tell item #{item} of sessions to write text \"#{command}\" \n
|
152
|
+
EOH
|
150
153
|
end
|
151
154
|
|
152
155
|
def keystroke(key, using="")
|
data/lib/termrc/cli.rb
CHANGED
@@ -3,7 +3,7 @@ require 'fileutils'
|
|
3
3
|
|
4
4
|
module Termrc
|
5
5
|
|
6
|
-
TERMRC_TEMPLATE = File.join( File.expand_path('../..', __FILE__), 'template', '
|
6
|
+
TERMRC_TEMPLATE = File.join( File.expand_path('../..', __FILE__), 'template', 'termfile.template' )
|
7
7
|
|
8
8
|
class Cli < Thor
|
9
9
|
include Thor::Actions
|
@@ -12,44 +12,56 @@ module Termrc
|
|
12
12
|
map 'l' => :list
|
13
13
|
map 's' => :start
|
14
14
|
|
15
|
-
desc 'create', 'Create
|
15
|
+
desc 'create', 'Create Termfile (Shortcut: c)'
|
16
16
|
def create
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
if (File.exist? '.termrc' or File.exists? 'Termfile')
|
18
|
+
say_this "Error: 'Termfile' already exists!"
|
19
|
+
return
|
20
20
|
else
|
21
|
-
|
22
|
-
FileUtils.cp TERMRC_TEMPLATE, '
|
23
|
-
|
24
|
-
say "Success! \n\n", :yellow
|
21
|
+
say_this "Creating Termfile...", :yellow
|
22
|
+
FileUtils.cp TERMRC_TEMPLATE, 'Termfile'
|
25
23
|
|
26
|
-
|
24
|
+
say_this "Success! \n", :yellow
|
25
|
+
say_this "Now run your new Termfile file by calling `termrc start`", :blue
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
30
|
-
desc 'list', 'List
|
29
|
+
desc 'list', 'List Termfiles in folder (Shortcut: l, Argument 0: folder (optional))'
|
31
30
|
def list(folder='.')
|
32
31
|
folder_description = folder == "." ? 'current folder' : "'#{folder}'"
|
33
|
-
|
34
|
-
|
35
|
-
a = `find #{folder} | grep -w \.termrc$`
|
36
|
-
say a
|
32
|
+
say_this "Looking for termrc files in #{folder_description}:", :yellow
|
37
33
|
|
38
|
-
|
34
|
+
a = `find #{folder} -name ".termrc" -o -name "Termfile"`
|
35
|
+
say_this a
|
36
|
+
|
37
|
+
say_this "None found.", :red if a.length < 1
|
39
38
|
end
|
40
39
|
|
41
40
|
desc 'start', 'Start termrc file (Shortcut: s, Argument 0: file (optional) )'
|
42
|
-
def start(file=
|
43
|
-
file =
|
44
|
-
|
41
|
+
def start(file='Termfile')
|
42
|
+
file = '.termrc' unless File.exists?(file)
|
43
|
+
|
44
|
+
if !File.exist? file
|
45
|
+
say_this "Could not find Termfile! Did you run `termrc create`?", :red
|
46
|
+
say_this "Did you run `termrc init`?", :yellow
|
47
|
+
return
|
48
|
+
elsif file == '.termrc'
|
49
|
+
say_this "Using deprecated #{file} file...", :yellow
|
50
|
+
end
|
45
51
|
|
46
|
-
|
47
|
-
|
52
|
+
say_this "Starting termrc using: '#{file}'", :blue
|
53
|
+
say_this "Please wait until all panes have fully launched!", :red
|
48
54
|
begin
|
49
55
|
Termrc::Base.new( File.expand_path(file) )
|
50
56
|
rescue Exception => e
|
51
|
-
|
52
|
-
|
57
|
+
say_this "Error while starting termrc:", :red
|
58
|
+
say_this e.to_s
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
no_commands do
|
63
|
+
def say_this(text="", color=:white)
|
64
|
+
say "** " + (text || ''), color
|
53
65
|
end
|
54
66
|
end
|
55
67
|
|
data/termrc.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
10
10
|
gem.executables << 'termrc'
|
11
11
|
gem.name = "termrc"
|
12
|
-
gem.version = '0.2.
|
12
|
+
gem.version = '0.2.1'
|
13
13
|
gem.license = 'MIT'
|
14
14
|
|
15
|
-
gem.add_runtime_dependency 'thor', '~> 0.18.
|
15
|
+
gem.add_runtime_dependency 'thor', '~> 0.18.1'
|
16
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: termrc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Gonzalez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.18.
|
19
|
+
version: 0.18.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.18.
|
26
|
+
version: 0.18.1
|
27
27
|
description: Take your iTerm2 environments with you wherever you go.
|
28
28
|
email:
|
29
29
|
- me@briangonzalez.org
|
@@ -33,13 +33,13 @@ extensions: []
|
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
35
|
- .gitignore
|
36
|
-
- .termrc
|
37
36
|
- README.md
|
38
37
|
- Rakefile
|
38
|
+
- Termfile.test
|
39
39
|
- bin/termrc
|
40
40
|
- lib/template/run.osascript
|
41
|
-
- lib/template/
|
42
|
-
- lib/template/
|
41
|
+
- lib/template/termfile.template
|
42
|
+
- lib/template/termfile_with_tabs.template
|
43
43
|
- lib/termrc.rb
|
44
44
|
- lib/termrc/base.rb
|
45
45
|
- lib/termrc/builder.rb
|
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
65
|
version: '0'
|
66
66
|
requirements: []
|
67
67
|
rubyforge_project:
|
68
|
-
rubygems_version: 2.
|
68
|
+
rubygems_version: 2.2.1
|
69
69
|
signing_key:
|
70
70
|
specification_version: 4
|
71
71
|
summary: Take your iTerm2 environments with you wherever you go.
|