termrc 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fcb14299cfde27760c6dfa122bda333155246e1
4
- data.tar.gz: e453a10c68003872229394eaef5d654dc37f259e
3
+ metadata.gz: fb96a3064c8c5a0f871c01ccd774a2ba87496723
4
+ data.tar.gz: 975c01579b724e0e619605c01d2f2ed712b17ef0
5
5
  SHA512:
6
- metadata.gz: 688a2d7b691bdff513ac81b37fd7e7bc2a31530cffe8e172f0a836df2e1e939110b09d58809447bfaea21ba3202c6725dd5be1d56b77eca4f66c0314b5931b74
7
- data.tar.gz: ab8cfa03d40e366e8570ff25c49dc965e63c4b5dbf28f32c0b20b59eb2e6a7e4eea41b11987addae0766d42e035b0baeff12c374ca04b362dc28e9e3aebe8259
6
+ metadata.gz: ce0de338003dd475d15aca399c9812faec70f3471e1254d5296beab79ddb815416f2bb16e9627dd3266d01e1e8beb30f92a7f586f00c3052213b9304b9210896
7
+ data.tar.gz: ba52abd1de34154e9a878832746d4386506bad01d6a151f4dbff271bf62c81643655c84b921662d01525eff9a32a79dd47a1ce9dfec1a49628b209b12e2ea5da
data/README.md CHANGED
@@ -14,8 +14,8 @@ $ termrc create
14
14
  $ termrc start
15
15
  ```
16
16
 
17
- .termrc file
18
- ----------
17
+ The Termfile
18
+ ------------
19
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
21
  Place the `Termfile` file at your project's root, then call `termrc start`. Voila!
@@ -42,11 +42,13 @@ A `Termfile` file is a YAML file which requires two keys: `commands` and a `layo
42
42
 
43
43
  <img src="https://rawgithub.com/briangonzalez/termrc/master/images/termrc-screen.png">
44
44
 
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.
45
+ You can supply an optional key, `root`, which indicates the root directory you'd like each command to be run inside of. Have a look at [this project's Termfile](https://github.com/briangonzalez/termrc/blob/master/Termfile.test) for an example.
46
+
47
+ You can also supply a `layout_type` value, either `row` or `column`, which denotes whether to use rows or columns as the means for splitting the window. This defaults to `layout_type: row`.
46
48
 
47
49
  **Tabs**
48
50
 
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.
51
+ 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/termfile_with_tabs.template) for an example.
50
52
 
51
53
  CLI
52
54
  ---
@@ -9,13 +9,13 @@ tell application "iTerm"
9
9
  -- Create a new session.
10
10
  [session]
11
11
 
12
- -- Create rows.
13
- [rows]
12
+ -- Create primary divider (rows or columns).
13
+ [primary]
14
14
 
15
15
  -- Sleep for a bit while we catch up.
16
16
  [sleep]
17
17
 
18
- -- Create panes within each row.
18
+ -- Create panes within each primary divider.
19
19
  [panes]
20
20
 
21
21
  -- Terminate first or last session, which are unused.
@@ -32,4 +32,4 @@ tell application "iTerm"
32
32
  -- Reposition window.
33
33
  -- set the bounds of the first window to {10, 10, 600, 600}
34
34
 
35
- end tell
35
+ end tell
@@ -0,0 +1,16 @@
1
+ root:
2
+ ~
3
+
4
+ layout_type: column
5
+
6
+ commands:
7
+ here: echo "Hello, here."
8
+ there: echo "Hello, there."
9
+ world: echo "Hello, world."
10
+ me: echo "Hello, me."
11
+ you: echo "Hello, you."
12
+
13
+ layout:
14
+ - [ here, there, here, there ] # row 1, with 2 panes
15
+ - [ world ] # row 2, with 1 pane
16
+ - [ me, you ] # row 3, with 2 panes
@@ -17,6 +17,7 @@ module Termrc
17
17
  @root = yml['root']
18
18
  @commands = yml['commands']
19
19
  @layout = yml['layout']
20
+ @columns = yml['layout_type'] == 'column' || false
20
21
  @cmd_index = 1
21
22
  end
22
23
 
@@ -38,13 +39,18 @@ module Termrc
38
39
  end
39
40
 
40
41
  def applescript_file(layout_array, index)
42
+ t = generateContents(layout_array, index)
43
+ writeTempFile(t)
44
+ end
45
+
46
+ def generateContents(layout_array, index)
41
47
  t = TEMPLATE
42
48
 
43
49
  if index > 0
44
50
  # All other tabs.
45
51
  t = t.gsub("[window_or_tab]", new_tab)
46
52
  t = t.gsub("[session]", current_session)
47
- t = t.gsub("[terminate_unused]", terminate_session('last'))
53
+ t = t.gsub("[terminate_unused]", terminate_session('last'))
48
54
  else
49
55
  # First tab.
50
56
  t = t.gsub("[window_or_tab]", new_window)
@@ -52,19 +58,22 @@ module Termrc
52
58
  t = t.gsub("[terminate_unused]", terminate_session)
53
59
  end
54
60
 
55
- t = t.gsub("[rows]", rows(layout_array))
61
+ t = t.gsub("[primary]", primary(layout_array))
56
62
  t = t.gsub("[sleep]", rest)
57
63
  t = t.gsub("[panes]", panes(layout_array))
58
64
  t = t.gsub("[commands]", commands(layout_array))
65
+ t
66
+ end
59
67
 
68
+ def writeTempFile(contents)
60
69
  file = Tempfile.new('termrc.osascript')
61
- file.write(t)
70
+ file.write(contents)
62
71
  file.close
63
72
  file
64
73
  end
65
74
 
66
- def rows(layout_array)
67
- Array.new( row_count(layout_array), new_row ).join("\n")
75
+ def primary(layout_array)
76
+ Array.new( primary_count(layout_array), @columns ? new_column : new_row ).join("\n")
68
77
  end
69
78
 
70
79
  def panes(layout_array)
@@ -72,7 +81,7 @@ module Termrc
72
81
  cmd = next_pane # back to the top
73
82
 
74
83
  layout_array.each do |cmds|
75
- cmd << Array.new( cmds.length - 1, new_column ).join("\n")
84
+ cmd << Array.new( cmds.length - 1, @columns ? new_row : new_column ).join("\n")
76
85
  cmd << next_pane
77
86
  cmd << "\n"
78
87
  end
@@ -85,7 +94,12 @@ module Termrc
85
94
 
86
95
  layout_array.each do |commands|
87
96
  commands.each do |name|
88
- cmd << execute_command( @cmd_index, @commands[name], name )
97
+ command = @commands[name]
98
+ if command
99
+ cmd << execute_command( @cmd_index, command, name )
100
+ else
101
+ puts "unknown command: #{name}"
102
+ end
89
103
  @cmd_index += 1
90
104
  end
91
105
  end
@@ -93,7 +107,7 @@ module Termrc
93
107
  cmd
94
108
  end
95
109
 
96
- def row_count(layout_array)
110
+ def primary_count(layout_array)
97
111
  layout_array.length
98
112
  end
99
113
 
@@ -161,4 +175,4 @@ module Termrc
161
175
 
162
176
  end
163
177
 
164
- end
178
+ end
data/lib/termrc/cli.rb CHANGED
@@ -8,11 +8,12 @@ module Termrc
8
8
  class Cli < Thor
9
9
  include Thor::Actions
10
10
 
11
- map 'c' => :create
12
- map 'l' => :list
13
- map 's' => :start
11
+ map 'c' => :create
12
+ map 'init' => :create
13
+ map 'l' => :list
14
+ map 's' => :start
14
15
 
15
- desc 'create', 'Create Termfile (Shortcut: c)'
16
+ desc 'create', 'Create Termfile (Shortcut: c / init)'
16
17
  def create
17
18
  if (File.exist? '.termrc' or File.exists? 'Termfile')
18
19
  say_this "Error: 'Termfile' already exists!"
@@ -66,4 +67,4 @@ module Termrc
66
67
  end
67
68
 
68
69
  end
69
- end
70
+ end
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.1'
12
+ gem.version = '0.2.2'
13
13
  gem.license = 'MIT'
14
14
 
15
15
  gem.add_runtime_dependency 'thor', '~> 0.18.1'
16
- end
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.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Gonzalez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-20 00:00:00.000000000 Z
11
+ date: 2014-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -39,6 +39,7 @@ files:
39
39
  - bin/termrc
40
40
  - lib/template/run.osascript
41
41
  - lib/template/termfile.template
42
+ - lib/template/termfile_columns.template
42
43
  - lib/template/termfile_with_tabs.template
43
44
  - lib/termrc.rb
44
45
  - lib/termrc/base.rb