teamocil 0.4.5 → 1.0

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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +14 -4
  3. data/.rubocop.yml +48 -0
  4. data/.travis.yml +2 -2
  5. data/Gemfile +1 -1
  6. data/{LICENSE → LICENSE.md} +0 -0
  7. data/README.md +124 -166
  8. data/Rakefile +12 -27
  9. data/bin/teamocil +3 -4
  10. data/lib/teamocil.rb +51 -4
  11. data/lib/teamocil/cli.rb +23 -90
  12. data/lib/teamocil/command/new_window.rb +16 -0
  13. data/lib/teamocil/command/rename_session.rb +9 -0
  14. data/lib/teamocil/command/rename_window.rb +9 -0
  15. data/lib/teamocil/command/select_layout.rb +9 -0
  16. data/lib/teamocil/command/select_pane.rb +9 -0
  17. data/lib/teamocil/command/select_window.rb +9 -0
  18. data/lib/teamocil/command/send_keys.rb +9 -0
  19. data/lib/teamocil/command/send_keys_to_pane.rb +9 -0
  20. data/lib/teamocil/command/split_window.rb +15 -0
  21. data/lib/teamocil/layout.rb +58 -36
  22. data/lib/teamocil/tmux/pane.rb +15 -0
  23. data/lib/teamocil/tmux/session.rb +28 -0
  24. data/lib/teamocil/tmux/window.rb +47 -0
  25. data/lib/teamocil/utils/closed_struct.rb +16 -0
  26. data/lib/teamocil/utils/option_parser.rb +56 -0
  27. data/lib/teamocil/version.rb +1 -1
  28. data/teamocil.gemspec +15 -16
  29. metadata +27 -54
  30. data/examples/four-splits.yml +0 -8
  31. data/examples/one-and-three-splits.yml +0 -8
  32. data/examples/six-splits.yml +0 -10
  33. data/examples/two-horizontal-splits.yml +0 -6
  34. data/examples/two-vertical-splits.yml +0 -6
  35. data/lib/teamocil/error.rb +0 -6
  36. data/lib/teamocil/layout/pane.rb +0 -66
  37. data/lib/teamocil/layout/session.rb +0 -30
  38. data/lib/teamocil/layout/window.rb +0 -77
  39. data/spec/cli_spec.rb +0 -79
  40. data/spec/fixtures/.my-fancy-layouts-directory/sample-3.yml +0 -10
  41. data/spec/fixtures/.teamocil/sample-2.yml +0 -10
  42. data/spec/fixtures/.teamocil/sample.yml +0 -10
  43. data/spec/fixtures/layouts.yml +0 -76
  44. data/spec/layout_spec.rb +0 -229
  45. data/spec/mock/cli.rb +0 -35
  46. data/spec/mock/layout.rb +0 -16
  47. data/spec/spec_helper.rb +0 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae4d2a262a756ec11e9a2e0f2be1c6bc8ecdfafe
4
- data.tar.gz: 4e5afa56cb394b6d433d16680e304b2776ae91e2
3
+ metadata.gz: ec181d7aedf97f5a86ff36a951f9e6778871d715
4
+ data.tar.gz: 898335772480c6026daa85a96ad83c083b553dba
5
5
  SHA512:
6
- metadata.gz: 5373b8ca262482ad3166bd046565bf8a96f68d7ac8c93d0cc8f9ba0ca3cff1ef40c036951e656cb518d1cf7c174f4936c67159f7d8a46eae5a33ac8643cbdea8
7
- data.tar.gz: d589b51c3cb65f77e3d4a78fa072a2c0206ecf7551e48d1b1a9bbd5a5358aac1fbdcc86c59a1fef3e0d66b93f4a2497539e5ca6f836d42fead7a24c2fd2c6eda
6
+ metadata.gz: 04b7e11004f212c832c72f4bc6e14690294dd7526c9fb820bbaac3c62c16a7bb5ecdc83f72f42e0b3c4ad9551d27986390b0539c799fcf3d61d86046fbee61e5
7
+ data.tar.gz: 066d82e108560b8633c6d79dd5d4ff1b57ec1596286c0738d81ecfc2110eacd6d212cda02c1cd713fc624eaa1a21e3c04c8053b218f45b56175f94233040fc82
data/.gitignore CHANGED
@@ -1,7 +1,17 @@
1
1
  *.gem
2
- .rvmrc
3
- .local*
2
+ *.rbc
3
+ .bundle
4
+ .config
4
5
  .yardoc
5
- doc
6
- pkg
7
6
  Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rubocop.yml ADDED
@@ -0,0 +1,48 @@
1
+ AllCops:
2
+ Include:
3
+ - Rakefile
4
+ - teamocil.gemspec
5
+
6
+ Documentation:
7
+ Enabled: false
8
+
9
+ Encoding:
10
+ Enabled: false
11
+
12
+ LineLength:
13
+ Max: 200
14
+
15
+ AccessModifierIndentation:
16
+ EnforcedStyle: outdent
17
+
18
+ IfUnlessModifier:
19
+ Enabled: false
20
+
21
+ CaseIndentation:
22
+ IndentWhenRelativeTo: case
23
+ IndentOneStep: true
24
+
25
+ MethodLength:
26
+ CountComments: false
27
+ Max: 20
28
+
29
+ SignalException:
30
+ Enabled: false
31
+
32
+ ColonMethodCall:
33
+ Enabled: false
34
+
35
+ AsciiComments:
36
+ Enabled: false
37
+
38
+ Lambda:
39
+ Enabled: false
40
+
41
+ RegexpLiteral:
42
+ Enabled: false
43
+
44
+ RedundantBegin:
45
+ Enabled: false
46
+
47
+ AssignmentInCondition:
48
+ Enabled: false
data/.travis.yml CHANGED
@@ -1,2 +1,2 @@
1
- rvm: 1.9.2
2
- script: "bundle exec rake spec"
1
+ rvm: 2.1.2
2
+ script: bundle exec phare
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source "http://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
  gemspec
File without changes
data/README.md CHANGED
@@ -1,199 +1,172 @@
1
- # Teamocil
1
+ <p align="center">
2
+ <a href="https://github.com/remiprev/teamocil">
3
+ <img src="http://i.imgur.com/NX2eV2X.png" alt="Teamocil" />
4
+ </a>
5
+ <br />
6
+ Teamocil is a simple tool used to automatically create sessions,<br /> windows and panes in <a href="http://tmux.sourceforge.net">tmux</a> with YAML files.
7
+ <br /><br />
8
+ <a href="https://rubygems.org/gems/teamocil"><img src="http://img.shields.io/gem/v/teamocil.svg" /></a>
9
+ <a href="https://travis-ci.org/remiprev/teamocil"><img src="http://img.shields.io/travis/remiprev/teamocil.svg" /></a>
10
+ </p>
2
11
 
3
- <a href="https://rubygems.org/gems/teamocil"><img src="http://img.shields.io/gem/v/teamocil.svg" /></a>
4
- <a href="https://travis-ci.org/remiprev/teamocil"><img src="http://img.shields.io/travis/remiprev/teamocil.svg" /></a>
12
+ ---
5
13
 
6
- Teamocil is a simple tool used to automatically create sessions, windows and panes in [tmux](http://tmux.sourceforge.net/) with YAML files.
7
-
8
- ## Usage
14
+ ## Installation
9
15
 
10
16
  ```bash
17
+ # Install the `teamocil` Ruby gem
11
18
  $ gem install teamocil
19
+
20
+ # Create your layout directory
12
21
  $ mkdir ~/.teamocil
22
+
23
+ # Edit ~/.teamocil/sample.yml (look for sample layouts in this very `README.md`)
13
24
  $ teamocil --edit sample
25
+
26
+ # Launch tmux
14
27
  $ tmux
28
+
29
+ # Run your newly-created sample layout
15
30
  $ teamocil sample
16
31
  ```
17
32
 
18
- ## Options
19
-
20
- * `--here` opens the session in the current window, do not create an empty first window.
21
- * `--layout` takes a custom file path to a YAML layout file.
22
- * `--edit` opens the layout file (whether or not `--layout` is used) with `$EDITOR`.
23
- * `--list` lists all available layouts in `./.teamocil` or `$TEAMOCIL_PATH`.
24
- * `--show` show the layout content instead of executing it.
25
-
26
- ## Layout file structure
27
-
28
- A layout file is a single YAML file located in `~/.teamocil` or `$TEAMOCIL_PATH` (eg. `~/.teamocil/my-project.yml`).
29
-
30
- ### Session
31
-
32
- You can wrap your entire layout file in a `session` and Teamocil will rename the current session (so that you can find it more easily when running `tmux list-sessions`) before creating your windows.
33
-
34
- #### Keys
35
-
36
- * `name` (the name of the session)
37
-
38
- #### Example
33
+ ## Usage
39
34
 
40
- ```yaml
41
- session:
42
- name: "my-awesome-session"
43
- windows:
44
- [windows list]
35
+ ```bash
36
+ $ teamocil [options] [layout-name]
45
37
  ```
46
38
 
47
- ### Windows
39
+ ### Global options
48
40
 
49
- If you are not using a top-level `session` key, then the first key of your layout file will be `windows`, an array of window items.
41
+ | Option | Description
42
+ |-------------|----------------------------
43
+ | `--list` | Lists all available layouts in `~/.teamocil`
50
44
 
51
- #### Item keys
45
+ ### Layout options
52
46
 
53
- * `name` (the name that will appear in `tmux` statusbar)
54
- * `root` (the directory in which every pane will be created)
55
- * `filters` (a hash of `before` and `after` commands to run for each pane)
56
- * `clear` (whether or not to prepend a `clear` command before the `before` filters list)
57
- * `layout` (a layout name or serialized string supported by the `tmux select-layout` command)
58
- * `panes` (an array of pane items)
59
- * `options` (a hash of `tmux` options, see `man tmux` for a list)
47
+ | Option | Description
48
+ |-------------|----------------------------
49
+ | `--layout` | Takes a custom file path to a YAML layout file instead of `[layout-name]`
50
+ | `--here` | Uses the current window as the layout’s first window
51
+ | `--edit` | Opens the layout file with `$EDITOR` instead of executing it
52
+ | `--show` | Shows the layout content instead of executing it
60
53
 
61
- #### Notes
54
+ ## Upgrading
62
55
 
63
- If you want to use a custom value for the `layout` key, running this command will give you the layout of the current window:
56
+ Teamocil 1.0 is a complete rewrite (from scratch!) of Teamocil. The code is now
57
+ very much simpler, cleaner and easier to maintain.
64
58
 
65
- ```bash
66
- $ tmux list-windows -F "#{window_active} #{window_layout}" | grep "^1" | cut -d " " -f 2
67
- ```
59
+ The downside of that is that several features were dropped during the rewrite
60
+ process, mostly because I didn’t actually use/need them and I got tired of
61
+ maintaining features I don’t think are useful.
68
62
 
69
- You can then use the value as a string, like so:
63
+ But hey, that’s just my opinion. Feel free to fork the repository and add as
64
+ many features as you want :smile:.
70
65
 
71
- ```yaml
72
- - name: "a-window-with-weird-layout"
73
- layout: "4d71,204x51,0,0{101x51,0,0,114,102x51,102,0[102x10,102,0,118,102x40,102,11,115]}"
74
- panes: …
75
- ```
66
+ ## Configuration
76
67
 
77
- #### Example
68
+ ### Windows
78
69
 
79
- ```yaml
80
- windows:
81
- - name: "my-first-window"
82
- clear: true
83
- options:
84
- synchronize-panes: true
85
- root: "~/Projects/foo-www"
86
- filters:
87
- before:
88
- - "echo 'Let’s use ruby-1.9.3 for each pane in this window.'"
89
- - "rbenv local 1.9.3-p374"
90
- panes:
91
- [panes list]
92
- - name: "my-second-window"
93
- layout: tiled
94
- root: "~/Projects/foo-api"
95
- panes:
96
- [panes list]
97
- - name: "my-third-window"
98
- layout: main-vertical
99
- root: "~/Projects/foo-daemons"
100
- panes:
101
- [panes list]
102
- ```
70
+ | Key | Description
71
+ |----------|----------------------------
72
+ | `name` | The tmux window name
73
+ | `root` | The path where all panes in the window will be started
74
+ | `layout` | The layout that will be set after all panes are created by Teamocil
75
+ | `panes` | An `Array` of panes
76
+ | `focus` | If set to `true`, the window will be selected after the layout has been executed
103
77
 
104
78
  ### Panes
105
79
 
106
- Every window must define an array of panes that will be created within it. A vertical or horizontal pane will be created, depending on whether the `width` or `height` parameter is used. If a `layout` option is used for the window, the `width` and `height` attributes won’t have any effect.
80
+ A pane can either be a `String` or a `Hash`. If it’s a `String`, Teamocil will
81
+ treat it as a single-command pane.
107
82
 
108
- #### Item keys
83
+ | Key | Description
84
+ |------------|----------------------------
85
+ | `commands` | An `Array` of commands that will be ran when the pane is created
86
+ | `focus` | If set to `true`, the pane will be selected after the layout has been executed
109
87
 
110
- * `cmd` (the commands to initially execute in the pane)
111
- * `width` (the pane width, in percentage)
112
- * `height` (the pane width, in percentage)
113
- * `target` (the pane to set focus on before creating the current one)
114
- * `focus` (the pane to set focus on after initializing all the panes for a window)
88
+ ## Examples
115
89
 
116
- #### Example
90
+ ### Simple two pane window
117
91
 
118
92
  ```yaml
119
93
  windows:
120
- - name: "my-first-window"
121
- root: "~/Projects/foo-www"
122
- layout: even-vertical
123
- filters:
124
- before: "rbenv local 2.0.0-p0"
125
- after: "echo 'I am done initializing this pane.'"
94
+ - name: sample-two-panes
95
+ root: ~/Code/sample/www
96
+ layout: even-horizontal
126
97
  panes:
127
- - cmd: "git status"
128
- - cmd: "bundle exec rails server --port 4000"
129
- focus: true
130
- - cmd:
131
- - "sudo service memcached start"
132
- - "sudo service mongodb start"
98
+ - git status
99
+ - rails server
133
100
  ```
134
101
 
135
- ## Layout examples
136
-
137
- See more example files in the `examples` directory.
138
-
139
- ### Simple two panes window
102
+ ```
103
+ .------------------.------------------.
104
+ | (0) | (1) |
105
+ | | |
106
+ | | |
107
+ | | |
108
+ | | |
109
+ | | |
110
+ | | |
111
+ | | |
112
+ | | |
113
+ '------------------'------------------'
114
+ ```
140
115
 
141
- #### Content of `~/.teamocil/sample-1.yml`
116
+ ### Simple three pane window
142
117
 
143
118
  ```yaml
144
119
  windows:
145
- - name: "sample-two-panes"
146
- root: "~/Code/sample/www"
147
- layout: even-horizontal
120
+ - name: sample-three-panes
121
+ root: ~/Code/sample/www
122
+ layout: main-vertical
148
123
  panes:
149
- - cmd: ["pwd", "ls -la"]
150
- - cmd: "rails server --port 3000"
124
+ - vim
125
+ - rails server
126
+ - git status
151
127
  ```
152
-
153
-
154
- #### Result of `$ teamocil sample-1`
155
128
 
156
- .------------------.------------------.
157
- | (0) | (1) |
158
- | | |
159
- | | |
160
- | | |
161
- | | |
162
- | | |
163
- | | |
164
- | | |
165
- | | |
166
- '------------------'------------------'
167
-
168
- ### Four tiled panes window
129
+ ```
130
+ .------------------.------------------.
131
+ | (0) | (1) |
132
+ | | |
133
+ | | |
134
+ | | |
135
+ | |------------------|
136
+ | | (2) |
137
+ | | |
138
+ | | |
139
+ | | |
140
+ '------------------'------------------'
141
+ ```
169
142
 
170
- #### Content of `~/.teamocil/sample-2.yml`
143
+ ### Simple four pane window
171
144
 
172
145
  ```yaml
173
146
  windows:
174
- - name: "sample-four-panes"
175
- root: "~/Code/sample/www"
147
+ - name: sample-two-panes
148
+ root: ~/Code/sample/www
176
149
  layout: tiled
177
150
  panes:
178
- - cmd: "pwd"
179
- - cmd: "pwd"
180
- - cmd: "pwd"
181
- - cmd: "pwd"
151
+ - vim
152
+ - foreman start web
153
+ - git status
154
+ - foreman start worker
182
155
  ```
183
156
 
184
- #### Result of `$ teamocil sample-2`
185
-
186
- .------------------.------------------.
187
- | (0) | (1) |
188
- | | |
189
- | | |
190
- | | |
191
- |------------------|------------------|
192
- | (3) | (2) |
193
- | | |
194
- | | |
195
- | | |
196
- '------------------'------------------'
157
+ ```
158
+ .------------------.------------------.
159
+ | (0) | (1) |
160
+ | | |
161
+ | | |
162
+ | | |
163
+ |------------------|------------------|
164
+ | (2) | (3) |
165
+ | | |
166
+ | | |
167
+ | | |
168
+ '------------------'------------------'
169
+ ```
197
170
 
198
171
  ## Extras
199
172
 
@@ -213,26 +186,11 @@ To get autocompletion when typing `teamocil <Tab>` in a bash session, add this l
213
186
  complete -W "$(teamocil --list)" teamocil
214
187
  ```
215
188
 
216
- ### ERB support
217
-
218
- You can use ERB in your layouts. For example, you can use an environment variable in a layout like so:
219
-
220
- ```yaml
221
- windows:
222
- - name: "erb-example"
223
- root: <%= ENV['MY_PROJECT_ROOT'] %>
224
- panes:
225
- - cmd: "pwd"
226
- ```
227
-
228
- ## Todo list
229
-
230
- * Making sure the layout is valid before executing it (ie. throw exceptions).
231
- * Add more specs.
232
-
233
189
  ## Contributors
234
190
 
235
- Feel free to contribute and submit issues/pull requests [on GitHub](https://github.com/remiprev/teamocil/issues), just like these fine folks did:
191
+ Feel free to contribute and submit issues/pull requests
192
+ [on GitHub](https://github.com/remiprev/teamocil/issues), just like these fine
193
+ folks did:
236
194
 
237
195
  * [@garno](https://github.com/garno)
238
196
  * [@jbourassa](https://github.com/jbourassa)
@@ -240,8 +198,8 @@ Feel free to contribute and submit issues/pull requests [on GitHub](https://gith
240
198
  * [@jscheel](https://github.com/jscheel)
241
199
  * [@mklappstuhl](https://github.com/mklappstuhl)
242
200
 
243
- Take a look at the `spec` folder before you do, and make sure `bundle exec rake spec` passes after your modifications :)
244
-
245
201
  ## License
246
202
 
247
- Teamocil is © 2011-2014 [Rémi Prévost](http://exomel.com) and may be freely distributed under the [MIT license](https://github.com/remiprev/teamocil/blob/master/LICENSE). See the `LICENSE` file.
203
+ Teamocil is © 2011-2014 [Rémi Prévost](http://exomel.com) and may be freely
204
+ distributed under the [MIT license](https://github.com/remiprev/teamocil/blob/master/LICENSE.md).
205
+ See the `LICENSE.md` file for more information.