termup 1.0.1 → 1.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.
- data/README.md +39 -13
- data/VERSION +1 -1
- data/lib/templates/template.yml +15 -10
- data/lib/termup/base.rb +41 -8
- data/lib/termup/cli.rb +1 -0
- data/termup.gemspec +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -13,7 +13,7 @@ Installation
|
|
13
13
|
Usage
|
14
14
|
-----
|
15
15
|
|
16
|
-
|
16
|
+
### Getting Started ###
|
17
17
|
|
18
18
|
Call the following command:
|
19
19
|
|
@@ -27,27 +27,53 @@ And now you're good to go:
|
|
27
27
|
|
28
28
|
$ termup start new_project
|
29
29
|
|
30
|
-
|
30
|
+
### YAML Syntax ###
|
31
31
|
|
32
32
|
# ~/.config/termup/new_project.yml
|
33
33
|
---
|
34
|
-
|
35
|
-
-
|
36
|
-
|
37
|
-
|
38
|
-
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
-
|
43
|
-
|
34
|
+
tabs:
|
35
|
+
- tab1:
|
36
|
+
- cd ~/foo/bar
|
37
|
+
- git status
|
38
|
+
- tab2:
|
39
|
+
- mysql -u root
|
40
|
+
- show databases;
|
41
|
+
- tab3: echo "hello world"
|
42
|
+
- tab4:
|
43
|
+
- cd ~/foo/project
|
44
|
+
- autotest
|
45
|
+
options:
|
46
|
+
iterm:
|
47
|
+
width: 2
|
48
|
+
height: 2
|
44
49
|
|
45
50
|
Tabs can contain a single command, or YAML arrays to execute multiple commands.
|
46
51
|
|
47
|
-
|
52
|
+
### Shortcut ###
|
48
53
|
|
49
54
|
Commands have a shortcut for even fewer keystrokes.
|
50
55
|
|
51
56
|
$ termup s new_project
|
52
57
|
|
53
58
|
That's equivalent to `termup start new_project`.
|
59
|
+
|
60
|
+
### iTerm 2 Split Pane Support ###
|
61
|
+
|
62
|
+
Specify iTerm option to use split pane.
|
63
|
+
|
64
|
+
options:
|
65
|
+
iterm:
|
66
|
+
width: 2
|
67
|
+
height: 2
|
68
|
+
|
69
|
+
The setting above turns to:
|
70
|
+
|
71
|
+
#################
|
72
|
+
# # #
|
73
|
+
# 1 # 3 #
|
74
|
+
# # #
|
75
|
+
#################
|
76
|
+
# # #
|
77
|
+
# 2 # 4 #
|
78
|
+
# # #
|
79
|
+
#################
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/lib/templates/template.yml
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
# COMMENT OF SCRIPT HERE
|
2
2
|
---
|
3
|
-
|
4
|
-
-
|
5
|
-
|
6
|
-
-
|
7
|
-
-
|
8
|
-
|
9
|
-
-
|
10
|
-
-
|
11
|
-
-
|
12
|
-
|
3
|
+
tabs:
|
4
|
+
- tab1:
|
5
|
+
- cd ~/foo/bar
|
6
|
+
- git status
|
7
|
+
- tab2:
|
8
|
+
- mysql -u root
|
9
|
+
- show databases;
|
10
|
+
- tab3: echo "hello world"
|
11
|
+
- tab4:
|
12
|
+
- cd ~/foo/project
|
13
|
+
- autotest
|
14
|
+
options:
|
15
|
+
iterm:
|
16
|
+
width: 2
|
17
|
+
height: 2
|
data/lib/termup/base.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
1
|
require 'appscript'
|
4
2
|
require 'yaml'
|
5
3
|
|
@@ -8,26 +6,61 @@ module Termup
|
|
8
6
|
include Appscript
|
9
7
|
|
10
8
|
def initialize(project)
|
11
|
-
@
|
12
|
-
|
13
|
-
|
9
|
+
@apps = app("System Events").application_processes
|
10
|
+
@frontmost = @apps.get.select{|i| i.frontmost.get }.map{|i| i.name.get }.first
|
11
|
+
return unless ["Terminal", "iTerm"].include?(@frontmost)
|
12
|
+
@terminal = app(@frontmost)
|
13
|
+
|
14
|
+
@project = YAML.load(File.read("#{TERMUP_DIR}/#{project}.yml"))
|
15
|
+
|
16
|
+
# Split panes for iTerm
|
17
|
+
split_panes if @frontmost == "iTerm" and @project['options']['iterm']
|
18
|
+
|
19
|
+
@project['tabs'].each do |hash|
|
14
20
|
tabname = hash.keys.first
|
15
21
|
cmds = hash.values.first
|
16
22
|
cmds = [cmds].flatten
|
17
23
|
tab = new_tab
|
18
24
|
cmds.each do |cmd|
|
19
|
-
@
|
25
|
+
case @frontmost
|
26
|
+
when "Terminal"
|
27
|
+
@terminal.do_script(cmd, :in => tab)
|
28
|
+
when "iTerm"
|
29
|
+
@terminal.current_terminal.current_session.write(:text => "#{cmd}")
|
30
|
+
end
|
20
31
|
end
|
21
32
|
end
|
22
33
|
end
|
23
34
|
|
24
35
|
def new_tab
|
25
36
|
if @got_first_tab_already
|
26
|
-
|
37
|
+
case @frontmost
|
38
|
+
when "Terminal"
|
39
|
+
@apps[@frontmost].keystroke("t", :using => :command_down)
|
40
|
+
when "iTerm"
|
41
|
+
@apps[@frontmost].keystroke("]", :using => :command_down)
|
42
|
+
end
|
27
43
|
end
|
28
44
|
@got_first_tab_already = true
|
29
45
|
sleep 0.01 # Allow some time to complete opening a new tab
|
30
|
-
@terminal.windows[1].tabs.last.get
|
46
|
+
@terminal.windows[1].tabs.last.get if @frontmost == "Terminal"
|
47
|
+
end
|
48
|
+
|
49
|
+
def split_panes
|
50
|
+
# Virtical splits
|
51
|
+
(@project['options']['iterm']['width'] - 1).times do |i|
|
52
|
+
@apps[@frontmost].keystroke("d", :using => :command_down)
|
53
|
+
end
|
54
|
+
# Back to home
|
55
|
+
@apps[@frontmost].keystroke("]", :using => :command_down)
|
56
|
+
# Horizontal splits
|
57
|
+
@project['options']['iterm']['width'].times do |i|
|
58
|
+
(@project['options']['iterm']['height'] - 1).times do |i|
|
59
|
+
@apps[@frontmost].keystroke("d", :using => [ :command_down, :shift_down ])
|
60
|
+
end
|
61
|
+
# Move to the right
|
62
|
+
@apps[@frontmost].keystroke("]", :using => :command_down)
|
63
|
+
end
|
31
64
|
end
|
32
65
|
end
|
33
66
|
end
|
data/lib/termup/cli.rb
CHANGED
@@ -25,6 +25,7 @@ module Termup
|
|
25
25
|
|
26
26
|
desc "edit PROJECT", "Edit termup project (Shortcut: e)"
|
27
27
|
def edit(project)
|
28
|
+
create(project) unless File.exists?(path(project))
|
28
29
|
say "please set $EDITOR in your .bash_profile." and return unless editor = ENV['EDITOR']
|
29
30
|
system("#{editor} #{path(project)}")
|
30
31
|
end
|
data/termup.gemspec
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: termup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0
|
5
|
+
version: 1.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kenn Ejima
|
@@ -99,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
99
|
requirements:
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
hash:
|
102
|
+
hash: 1610649593229339461
|
103
103
|
segments:
|
104
104
|
- 0
|
105
105
|
version: "0"
|