lab42_tmux2 0.0.1 → 0.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 +49 -4
- data/lib/lab42/tmux.rb +7 -2
- data/lib/lab42/tmux/session.rb +1 -1
- data/lib/lab42/tmux/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b6fe48106bf796c4c3a16e0e0031c26f65600df
|
4
|
+
data.tar.gz: 8010ef98d1e5742c2865e003e0b030b1c72f4173
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23be8b8408635c826a19540db11e9388a0ee44bd5ee9d0bc80e83c4756c8cff14d7ed3b6dd1dea2f38e8a759429d7300acb7146ce864b506671bee22eb2e15f9
|
7
|
+
data.tar.gz: a12f3f65af2553b12f33a75c206d2417cc56978230be7b56f60d79cfe2a292715ca947c138a48c82a9dac384943018c50a7035552988af4b9382722e695715f5
|
data/README.md
CHANGED
@@ -24,10 +24,6 @@ A simple API for launching tmux sessions from Ruby scripts
|
|
24
24
|
require 'lab42/tmux/autoimport'
|
25
25
|
|
26
26
|
session "vi_session" do
|
27
|
-
configure do | c |
|
28
|
-
c.home '.' # Would have been the default
|
29
|
-
c.window_automatic_rename true # Default is false
|
30
|
-
end
|
31
27
|
new_window 'vi' do
|
32
28
|
send_keys 'vi .'
|
33
29
|
wait_for '.. (up a dir)' # NERDTree pane has loaded (not yet implemented)
|
@@ -40,6 +36,21 @@ A simple API for launching tmux sessions from Ruby scripts
|
|
40
36
|
end
|
41
37
|
```
|
42
38
|
|
39
|
+
### Configuration
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
require 'lab42/tmux/autoimport'
|
43
|
+
|
44
|
+
config do
|
45
|
+
window_automatic_rename true # now there will be no `set-window-option -g automatic-rename off`
|
46
|
+
end
|
47
|
+
|
48
|
+
session "sh-session" do
|
49
|
+
new_window 'console' # opens a second window
|
50
|
+
end
|
51
|
+
|
52
|
+
```
|
53
|
+
|
43
54
|
### Hooks
|
44
55
|
|
45
56
|
Add a `after_new_window` hook for tmux commands to be executed after the creation of a new
|
@@ -54,6 +65,40 @@ window.
|
|
54
65
|
end
|
55
66
|
```
|
56
67
|
|
68
|
+
### Window Events
|
69
|
+
|
70
|
+
The real use case for which Ruby was much better than shell scripts was the `wait_for` method
|
71
|
+
as it allows us to wait for some text in a pane to be shown before doing some action.
|
72
|
+
|
73
|
+
This is a real use case which will open vi with _NERDTree_, wait for NERDTree to split panes
|
74
|
+
and only then switch to the right hand side split pane (of vi, not tmux).
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
|
78
|
+
config
|
79
|
+
# options for wait_for
|
80
|
+
pre_wait_interval 0.1 # Before checking for text
|
81
|
+
post_wait_interval 0.1 # After text has shown up in pane
|
82
|
+
wait_timeout 4 # Do not wait longer than that
|
83
|
+
|
84
|
+
verbose true # Talk to stdout for post mortem analyse
|
85
|
+
end
|
86
|
+
|
87
|
+
new_session 'lab42_core' do
|
88
|
+
new_window 'vi' do
|
89
|
+
send_keys 'vi .'
|
90
|
+
wait_for "up a dir" do # Block will be executed iff text appears
|
91
|
+
# before timeout only
|
92
|
+
send_keys_raw 'C-w', 'l'
|
93
|
+
send_keys ':e README.md'
|
94
|
+
send_keys ':so local.vim'
|
95
|
+
send_keys_raw 'ziG'
|
96
|
+
end
|
97
|
+
# Script continues after timeout or appearance of text
|
98
|
+
# ...
|
99
|
+
end
|
100
|
+
end
|
101
|
+
```
|
57
102
|
|
58
103
|
### Plugins
|
59
104
|
|
data/lib/lab42/tmux.rb
CHANGED
@@ -5,9 +5,14 @@ require_relative 'tmux/session'
|
|
5
5
|
module Lab42
|
6
6
|
module Tmux
|
7
7
|
|
8
|
-
def
|
8
|
+
def config &block
|
9
|
+
$config = Config.new
|
10
|
+
$config.instance_exec( &block )
|
11
|
+
end
|
12
|
+
|
13
|
+
def new_session session_name, &block
|
9
14
|
raise ArgumentError, 'No block provided' unless block
|
10
|
-
session = Session.new session_name
|
15
|
+
session = Session.new session_name
|
11
16
|
session.run &block
|
12
17
|
end
|
13
18
|
|
data/lib/lab42/tmux/session.rb
CHANGED
data/lib/lab42/tmux/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lab42_tmux2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Dober
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: forwarder2
|