teamocil 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -3
- data/lib/teamocil.rb +5 -0
- data/lib/teamocil/cli.rb +2 -2
- data/lib/teamocil/layout.rb +1 -1
- data/lib/teamocil/tmux/options.rb +15 -0
- data/lib/teamocil/tmux/pane.rb +8 -10
- data/lib/teamocil/tmux/session.rb +24 -17
- data/lib/teamocil/tmux/window.rb +37 -34
- data/lib/teamocil/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7dcef230e6b52430c6fd283000e6ecffd28e45d9
|
4
|
+
data.tar.gz: 6359ec6cb545a88e2325f16449d07302f346fb6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e80f9d9750d444a6323d146d48c074f33dde63fd0cdf7e674d924fb03d72912109f8092eac2fd98a83e07f64d5c259173d859b05ba38a05018370ed4624c095e
|
7
|
+
data.tar.gz: 3e90ff56c60c676f8616f33b896849bc4c912d3878f11af411b0845f6dc3caaa30b460716f8afc80b1f3d1787e943a403af5913eee6b5f9f24355798896c1adb
|
data/README.md
CHANGED
@@ -60,8 +60,11 @@ The downside of that is that several features were dropped during the rewrite
|
|
60
60
|
process, mostly because I didn’t actually use/need them and I got tired of
|
61
61
|
maintaining features I don’t think are useful.
|
62
62
|
|
63
|
-
|
64
|
-
|
63
|
+
You *might* have to clean up your layout files after upgrading to 1.0. I’m
|
64
|
+
sorry about that. The documentation in `README.md` should help you find which
|
65
|
+
keys are now supported.
|
66
|
+
|
67
|
+
Feel free to fork the repository and add back as many features as you want :)
|
65
68
|
|
66
69
|
## Configuration
|
67
70
|
|
@@ -122,8 +125,10 @@ windows:
|
|
122
125
|
layout: main-vertical
|
123
126
|
panes:
|
124
127
|
- vim
|
128
|
+
- commands:
|
129
|
+
- git pull
|
130
|
+
- git status
|
125
131
|
- rails server
|
126
|
-
- git status
|
127
132
|
```
|
128
133
|
|
129
134
|
```
|
data/lib/teamocil.rb
CHANGED
@@ -27,6 +27,7 @@ require 'teamocil/command/split_window'
|
|
27
27
|
require 'teamocil/tmux/session'
|
28
28
|
require 'teamocil/tmux/window'
|
29
29
|
require 'teamocil/tmux/pane'
|
30
|
+
require 'teamocil/tmux/options'
|
30
31
|
|
31
32
|
module Teamocil
|
32
33
|
class << self
|
@@ -47,6 +48,10 @@ module Teamocil
|
|
47
48
|
Kernel.system(*args)
|
48
49
|
end
|
49
50
|
|
51
|
+
def self.query_system(command)
|
52
|
+
`#{command}`
|
53
|
+
end
|
54
|
+
|
50
55
|
def self.parse_options!(arguments: nil)
|
51
56
|
parser = OptionParser.new(arguments: arguments)
|
52
57
|
@options = parser.parsed_options
|
data/lib/teamocil/cli.rb
CHANGED
@@ -6,10 +6,10 @@ module Teamocil
|
|
6
6
|
Teamocil.parse_options!(arguments: arguments)
|
7
7
|
|
8
8
|
# List available layouts
|
9
|
-
return Layout.print_available_layouts(directory: root) if Teamocil.options[:list]
|
9
|
+
return Teamocil::Layout.print_available_layouts(directory: root) if Teamocil.options[:list]
|
10
10
|
|
11
11
|
# Fetch the Layout object
|
12
|
-
layout = Layout.new(path: layout_file_path)
|
12
|
+
layout = Teamocil::Layout.new(path: layout_file_path)
|
13
13
|
|
14
14
|
# Open layout file in $EDITOR
|
15
15
|
return layout.edit! if Teamocil.options[:edit]
|
data/lib/teamocil/layout.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Teamocil
|
2
|
+
module Tmux
|
3
|
+
class Options
|
4
|
+
def self.fetch_option(option, default: nil)
|
5
|
+
value = Teamocil.query_system("tmux show-options -gv #{option}").chomp
|
6
|
+
value.empty? ? default : value.to_i
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.fetch_window_option(option, default: nil)
|
10
|
+
value = Teamocil.query_system("tmux show-window-options -gv #{option}").chomp
|
11
|
+
value.empty? ? default : value.to_i
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/teamocil/tmux/pane.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
module Teamocil
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
module Tmux
|
3
|
+
class Pane < ClosedStruct.new(:index, :root, :commands, :focus, :first)
|
4
|
+
def as_tmux
|
5
|
+
[].tap do |tmux|
|
6
|
+
tmux << Teamocil::Command::SplitWindow.new(root: root) unless first
|
7
|
+
tmux << Teamocil::Command::SendKeysToPane.new(index: index, keys: commands.join('; '))
|
8
|
+
tmux << Teamocil::Command::SendKeysToPane.new(index: index, keys: 'Enter')
|
9
|
+
end
|
8
10
|
end
|
9
11
|
end
|
10
|
-
|
11
|
-
def first?
|
12
|
-
index == 1
|
13
|
-
end
|
14
12
|
end
|
15
13
|
end
|
@@ -1,27 +1,34 @@
|
|
1
1
|
module Teamocil
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
module Tmux
|
3
|
+
class Session < ClosedStruct.new(:name, :windows)
|
4
|
+
def initialize(object)
|
5
|
+
super
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
# Sessions need a name
|
8
|
+
self.name = "teamocil-session-#{rand(1_000_000)}" unless name
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
self.windows = windows.each_with_index.map do |window, index|
|
11
|
+
# Windows need to know their position
|
12
|
+
window.merge! index: index + window_base_index
|
13
|
+
window.merge! first: index.zero?
|
12
14
|
|
13
|
-
|
15
|
+
Teamocil::Tmux::Window.new(window)
|
16
|
+
end
|
14
17
|
end
|
15
|
-
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
def as_tmux
|
20
|
+
[].tap do |tmux|
|
21
|
+
tmux << Teamocil::Command::RenameSession.new(name: name)
|
22
|
+
tmux << windows.map(&:as_tmux)
|
23
|
+
|
24
|
+
# Set the focus on the right window or do nothing
|
25
|
+
focused_window = windows.find(&:focus)
|
26
|
+
tmux << Teamocil::Command::SelectWindow.new(index: focused_window.index) if focused_window
|
27
|
+
end
|
28
|
+
end
|
21
29
|
|
22
|
-
|
23
|
-
|
24
|
-
tmux << Command::SelectWindow.new(index: focused_window.index) if focused_window
|
30
|
+
def window_base_index
|
31
|
+
@window_base_index ||= Teamocil::Tmux::Options.fetch_option('base-index', default: 0)
|
25
32
|
end
|
26
33
|
end
|
27
34
|
end
|
data/lib/teamocil/tmux/window.rb
CHANGED
@@ -1,46 +1,49 @@
|
|
1
1
|
module Teamocil
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
module Tmux
|
3
|
+
class Window < ClosedStruct.new(:index, :root, :focus, :layout, :name, :panes, :first)
|
4
|
+
def initialize(object)
|
5
|
+
super
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
self.panes ||= splits
|
8
|
+
self.panes = panes.each_with_index.map do |pane, index|
|
9
|
+
# Support single command instead of `commands` key in Hash
|
10
|
+
pane = { commands: [pane] } if pane.is_a?(String)
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
# Panes need to know their position
|
13
|
+
pane.merge! index: index + pane_base_index
|
14
|
+
pane.merge! first: index.zero?
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
+
# Panes need know the window root directory
|
17
|
+
pane.merge! root: root
|
16
18
|
|
17
|
-
|
19
|
+
Teamocil::Tmux::Pane.new(pane)
|
20
|
+
end
|
18
21
|
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def first?
|
22
|
-
index == 1
|
23
|
-
end
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
def as_tmux
|
24
|
+
[].tap do |tmux|
|
25
|
+
# Rename the current window or create a new one
|
26
|
+
if Teamocil.options[:here] && first
|
27
|
+
tmux << Teamocil::Command::RenameWindow.new(name: name)
|
28
|
+
else
|
29
|
+
tmux << Teamocil::Command::NewWindow.new(name: name, root: root)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Execute all panes commands
|
33
|
+
tmux << panes.map(&:as_tmux)
|
34
|
+
|
35
|
+
# Select the window layout
|
36
|
+
tmux << Teamocil::Command::SelectLayout.new(layout: layout)
|
37
|
+
|
38
|
+
# Set the focus on the right pane or the first one
|
39
|
+
focused_pane = panes.find(&:focus)
|
40
|
+
focused_index = focused_pane ? focused_pane.index : pane_base_index
|
41
|
+
tmux << Teamocil::Command::SelectPane.new(index: focused_index)
|
32
42
|
end
|
43
|
+
end
|
33
44
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
# Select the window layout
|
38
|
-
tmux << Command::SelectLayout.new(layout: layout)
|
39
|
-
|
40
|
-
# Set the focus on the right pane or the first one
|
41
|
-
focused_pane = panes.find(&:focus)
|
42
|
-
focused_index = focused_pane ? focused_pane.index : 0
|
43
|
-
tmux << Command::SelectPane.new(index: focused_index)
|
45
|
+
def pane_base_index
|
46
|
+
@pane_base_index ||= Teamocil::Tmux::Options.fetch_window_option('pane-base-index', default: 0)
|
44
47
|
end
|
45
48
|
end
|
46
49
|
end
|
data/lib/teamocil/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teamocil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rémi Prévost
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -80,6 +80,7 @@ files:
|
|
80
80
|
- lib/teamocil/command/send_keys_to_pane.rb
|
81
81
|
- lib/teamocil/command/split_window.rb
|
82
82
|
- lib/teamocil/layout.rb
|
83
|
+
- lib/teamocil/tmux/options.rb
|
83
84
|
- lib/teamocil/tmux/pane.rb
|
84
85
|
- lib/teamocil/tmux/session.rb
|
85
86
|
- lib/teamocil/tmux/window.rb
|