iterm_window 0.3.5 → 0.3.6
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.
- data/LICENSE +2 -2
- data/README.md +78 -0
- data/lib/iterm_window.rb +2 -2
- metadata +2 -2
- data/README.rdoc +0 -69
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2014 Chris Powers
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# iTermWindow
|
2
|
+
|
3
|
+
*Developed March 17, 2008 by Chris Powers*
|
4
|
+
|
5
|
+
The `ItermWindow` class models an iTerm terminal window and allows for full control via Ruby commands.
|
6
|
+
Under the hood, this class is a wrapper of iTerm's Applescript scripting API. Methods are used to
|
7
|
+
generate Applescript code which is run as an `osascript` command when the ItermWindow initialization
|
8
|
+
block is closed.
|
9
|
+
|
10
|
+
`ItermWindow::Tab` models a tab (session) in an iTerm terminal window and allows for it to be controlled by Ruby.
|
11
|
+
These tabs can be created with either the `ItermWindow#open_bookmark` method or the `ItermWindow#open_tab`
|
12
|
+
method. Each tab is given a name (symbol) by which it can be accessed later in the code using
|
13
|
+
the tab name as an `ItermWindow` method.
|
14
|
+
|
15
|
+
## EXAMPLE - Open a new iTerm window, cd to a project and open it in TextMate
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
require 'rubygems'
|
19
|
+
require 'iterm_window'
|
20
|
+
|
21
|
+
ItermWindow.open do
|
22
|
+
open_tab :my_tab do
|
23
|
+
write "cd ~/projects/my_project/trunk"
|
24
|
+
write "mate ./"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
```
|
28
|
+
|
29
|
+
## EXAMPLE - Use the current iTerm window, cd to a project and open in TextMate, launch the server and the console and title them
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
ItermWindow.current do
|
33
|
+
open_tab :project_dir do
|
34
|
+
write "cd ~/projects/my_project/trunk"
|
35
|
+
write "mate ./"
|
36
|
+
set_title "MyProject Dir"
|
37
|
+
end
|
38
|
+
open_tab :server do
|
39
|
+
write "cd ~/projects/my_project/trunk"
|
40
|
+
write "script/server -p 3005"
|
41
|
+
set_title "MyProject Server"
|
42
|
+
end
|
43
|
+
open_tab :console do
|
44
|
+
write "cd ~/projects/my_project/trunk"
|
45
|
+
write "script/console"
|
46
|
+
set_title "MyProject Console"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
51
|
+
## EXAMPLE - Same thing, but use bookmarks that were made for the server and console. Also, switch focus back to project dir.
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
ItermWindow.current do
|
55
|
+
open_tab :project_dir do
|
56
|
+
write "cd ~/projects/my_project/trunk"
|
57
|
+
write "mate ./"
|
58
|
+
end
|
59
|
+
open_bookmark :server, 'MyProject Server'
|
60
|
+
open_bookmark :console, 'MyProject Console'
|
61
|
+
project_dir.select
|
62
|
+
end
|
63
|
+
```
|
64
|
+
|
65
|
+
## EXAMPLE - Arbitrarily open two tabs, switch between them and run methods/blocks with Tab#select method and Tab#write directly
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
ItermWindow.open do
|
69
|
+
open_tab :first_tab
|
70
|
+
open_tab :second_tab
|
71
|
+
first_tab.select do
|
72
|
+
write 'cd ~/projects'
|
73
|
+
write 'ls'
|
74
|
+
end
|
75
|
+
second_tab.write "echo 'hello there!'"
|
76
|
+
first_tab.select # brings first tab back to focus
|
77
|
+
end
|
78
|
+
```
|
data/lib/iterm_window.rb
CHANGED
@@ -119,7 +119,7 @@ class ItermWindow
|
|
119
119
|
|
120
120
|
# Initializes the terminal window
|
121
121
|
def run_commands(window_type, &block)
|
122
|
-
window_types = {:new => '(make new terminal)', :current => '
|
122
|
+
window_types = {:new => '(make new terminal)', :current => 'current terminal'}
|
123
123
|
raise ArgumentError, "ItermWindow#run_commands should be passed :new or :current." unless window_types.keys.include? window_type
|
124
124
|
output "tell application 'iTerm'"
|
125
125
|
output "activate"
|
@@ -212,4 +212,4 @@ class ItermWindow
|
|
212
212
|
|
213
213
|
end
|
214
214
|
|
215
|
-
end
|
215
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iterm_window
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -17,7 +17,7 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- README.
|
20
|
+
- README.md
|
21
21
|
- LICENSE
|
22
22
|
- lib/iterm_window.rb
|
23
23
|
homepage: http://github.com/chrisjpowers/iterm_window
|
data/README.rdoc
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
= iTermWindow
|
2
|
-
|
3
|
-
<em>Developed March 17, 2008 by Chris Powers</em>
|
4
|
-
|
5
|
-
The ItermWindow class models an iTerm terminal window and allows for full control via Ruby commands.
|
6
|
-
Under the hood, this class is a wrapper of iTerm's Applescript scripting API. Methods are used to
|
7
|
-
generate Applescript code which is run as an <tt>osascript</tt> command when the ItermWindow initialization
|
8
|
-
block is closed.
|
9
|
-
|
10
|
-
ItermWindow::Tab models a tab (session) in an iTerm terminal window and allows for it to be controlled by Ruby.
|
11
|
-
These tabs can be created with either the ItermWindow#open_bookmark method or the ItermWindow#open_tab
|
12
|
-
method. Each tab is given a name (symbol) by which it can be accessed later in the code using
|
13
|
-
the tab name as an ItermWindow method.
|
14
|
-
|
15
|
-
== EXAMPLE - Open a new iTerm window, cd to a project and open it in TextMate
|
16
|
-
|
17
|
-
require 'rubygems'
|
18
|
-
require 'iterm_window'
|
19
|
-
|
20
|
-
ItermWindow.open do
|
21
|
-
open_tab :my_tab do
|
22
|
-
write "cd ~/projects/my_project/trunk"
|
23
|
-
write "mate ./"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
== EXAMPLE - Use the current iTerm window, cd to a project and open in TextMate, launch the server and the console and title them
|
28
|
-
|
29
|
-
ItermWindow.current do
|
30
|
-
open_tab :project_dir do
|
31
|
-
write "cd ~/projects/my_project/trunk"
|
32
|
-
write "mate ./"
|
33
|
-
set_title "MyProject Dir"
|
34
|
-
end
|
35
|
-
open_tab :server do
|
36
|
-
write "cd ~/projects/my_project/trunk"
|
37
|
-
write "script/server -p 3005"
|
38
|
-
set_title "MyProject Server"
|
39
|
-
end
|
40
|
-
open_tab :console do
|
41
|
-
write "cd ~/projects/my_project/trunk"
|
42
|
-
write "script/console"
|
43
|
-
set_title "MyProject Console"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
== EXAMPLE - Same thing, but use bookmarks that were made for the server and console. Also, switch focus back to project dir.
|
48
|
-
|
49
|
-
ItermWindow.current do
|
50
|
-
open_tab :project_dir do
|
51
|
-
write "cd ~/projects/my_project/trunk"
|
52
|
-
write "mate ./"
|
53
|
-
end
|
54
|
-
open_bookmark :server, 'MyProject Server'
|
55
|
-
open_bookmark :console, 'MyProject Console'
|
56
|
-
project_dir.select
|
57
|
-
|
58
|
-
== EXAMPLE - Arbitrarily open two tabs, switch between them and run methods/blocks with Tab#select method and Tab#write directly
|
59
|
-
|
60
|
-
ItermWindow.open do
|
61
|
-
open_tab :first_tab
|
62
|
-
open_tab :second_tab
|
63
|
-
first_tab.select do
|
64
|
-
write 'cd ~/projects'
|
65
|
-
write 'ls'
|
66
|
-
end
|
67
|
-
second_tab.write "echo 'hello there!'"
|
68
|
-
first_tab.select # brings first tab back to focus
|
69
|
-
end
|