iterm_cli 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +96 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/exe/iterm +3 -0
- data/iterm_cli.gemspec +28 -0
- data/lib/iterm_cli/cli.rb +61 -0
- data/lib/iterm_cli/session_manager.rb +108 -0
- data/lib/iterm_cli/terminal/function.rb +26 -0
- data/lib/iterm_cli/terminal/list_sessions.rb +25 -0
- data/lib/iterm_cli/terminal/new_session.rb +72 -0
- data/lib/iterm_cli/terminal/send_keys.rb +41 -0
- data/lib/iterm_cli/terminal.rb +8 -0
- data/lib/iterm_cli/version.rb +3 -0
- data/lib/iterm_cli.rb +8 -0
- metadata +137 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ef00a0f6bc21b02fcfffffda443665121e392889
|
4
|
+
data.tar.gz: c39b513018eceeb2ae7f672fe71c7769c9388883
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 684dc54eb10dfb22259fdfcabee8e608bab5081d03fde55f921061ecc030a9b4b45827cb7f4a9ee5c358086c25fbea2ca76e137d889c6c7e4354ee798f0e6387
|
7
|
+
data.tar.gz: b9343055ffb8a5efef3bdf2ef2f93ee1be4d3185bb1a03a1931ea3f57d75cd97a217690fdcf4b6638744116653169b3a284336f66f8efa777a8fc5b52af3da4d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
This document provides community guidelines for a safe, respectful, productive,
|
2
|
+
and collaborative place for any person who is willing to contribute to the Opal
|
3
|
+
community. It applies to all “collaborative space”, which is defined as
|
4
|
+
community communications channels (such as mailing lists, submitted patches,
|
5
|
+
commit comments, etc.).
|
6
|
+
|
7
|
+
* Participants will be tolerant of opposing views.
|
8
|
+
* Participants must ensure that their language and actions are free of personal
|
9
|
+
attacks and disparaging personal remarks.
|
10
|
+
* When interpreting the words and actions of others, participants should always
|
11
|
+
assume good intentions.
|
12
|
+
* Behaviour which can be reasonably considered harassment will not be
|
13
|
+
tolerated.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 labocho
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# iTerm CLI
|
2
|
+
|
3
|
+
Command line interface for [iTerm 2](https://www.iterm2.com/). Inspired by [tmux](https://tmux.github.io/) and [tmuxinator](https://github.com/tmuxinator/tmuxinator).
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
|
7
|
+
Ruby 1.9.3 or later.
|
8
|
+
iTerm2 Build 3.0.4 or later.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
$ git clone https://github.com/labocho/iterm_cli
|
13
|
+
$ cd iterm_cli
|
14
|
+
$ rake install
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
# If no arguments, show help.
|
19
|
+
$ iterm
|
20
|
+
|
21
|
+
### new-session
|
22
|
+
|
23
|
+
# `iterm new-session` creates new session (tab)
|
24
|
+
$ iterm new-session
|
25
|
+
|
26
|
+
# with command, execute in created session
|
27
|
+
$ iterm new-session top
|
28
|
+
$ iterm new-session sleep 3
|
29
|
+
$ iterm new-session 'sleep 3'
|
30
|
+
|
31
|
+
# session name will be command name.
|
32
|
+
# --name (or -n) option names session explicitly.
|
33
|
+
$ iterm new-session --name=server rails server
|
34
|
+
|
35
|
+
### send-keys
|
36
|
+
|
37
|
+
# `iterm send-keys` types keys to target session
|
38
|
+
$ iterm new-session -n foo zsh
|
39
|
+
$ iterm send-keys --target foo exit
|
40
|
+
|
41
|
+
# C-* indicates control key
|
42
|
+
$ iterm new-session top
|
43
|
+
$ iterm send-keys --target top C-c # send control-c
|
44
|
+
|
45
|
+
### sessions
|
46
|
+
|
47
|
+
`iterm sessions` manages multi sessions by file named `.iterm-sessions` in current directory.
|
48
|
+
`.iterm-sessions` should be written in YAML (http://yaml.org/).
|
49
|
+
|
50
|
+
# keys are session names
|
51
|
+
console:
|
52
|
+
# `command` passes `iterm new-session` when started
|
53
|
+
command: rails console
|
54
|
+
# `kill` passes `iterm send-keys` when stopped
|
55
|
+
kill: exit
|
56
|
+
# shorthand style (killed by control-c)
|
57
|
+
server: rails server
|
58
|
+
|
59
|
+
`iterm sessions` have subcommands below.
|
60
|
+
|
61
|
+
# `iterm sessions ls` lists sessions defined
|
62
|
+
# marked for session exists.
|
63
|
+
$ iterm sessions ls
|
64
|
+
console
|
65
|
+
* server
|
66
|
+
|
67
|
+
|
68
|
+
# `iterm sessions start` starts all sessions.
|
69
|
+
# If session exists, do nothing for the session.
|
70
|
+
$ iterm sessions start
|
71
|
+
|
72
|
+
# If pass session name, start the session (if not exists).
|
73
|
+
$ iterm sessions start server
|
74
|
+
|
75
|
+
|
76
|
+
# `iterm sessions kill` stops all sessions.
|
77
|
+
# If session does not exist, do nothing.
|
78
|
+
$ iterm sessions kill
|
79
|
+
|
80
|
+
# If pass session name, kill the session (if exists).
|
81
|
+
$ iterm sessions kill server
|
82
|
+
|
83
|
+
## Development
|
84
|
+
|
85
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
86
|
+
|
87
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
88
|
+
|
89
|
+
## Contributing
|
90
|
+
|
91
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/labocho/iterm_cli.
|
92
|
+
|
93
|
+
## License
|
94
|
+
|
95
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
96
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "iterm_cli"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/exe/iterm
ADDED
data/iterm_cli.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'iterm_cli/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "iterm_cli"
|
8
|
+
spec.version = ITermCLI::VERSION
|
9
|
+
spec.authors = ["labocho"]
|
10
|
+
spec.email = ["labocho@penguinlab.jp"]
|
11
|
+
|
12
|
+
spec.summary = %q{Command line interface for iTerm2}
|
13
|
+
spec.description = %q{Command line interface for iTerm2}
|
14
|
+
spec.homepage = "https://github.com/labocho/iterm_cli"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency "thor", "~> 0.19.1"
|
23
|
+
spec.add_dependency "thor-zsh_completion", "~> 0.1.1"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "thor/zsh_completion"
|
3
|
+
|
4
|
+
module ITermCLI
|
5
|
+
class SessionsCommand < Thor
|
6
|
+
namespace "sessions"
|
7
|
+
|
8
|
+
desc "start [SESSION_NAME]", "Start all sessions if it's not started"
|
9
|
+
def start(*session_names)
|
10
|
+
SessionManager.load(".iterm-sessions").start(session_names)
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "kill [SESSION_NAME]", "Kill all sessions if it's started"
|
14
|
+
def kill(*session_names)
|
15
|
+
SessionManager.load(".iterm-sessions").kill(session_names)
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "ls", "List sessions"
|
19
|
+
def ls(*session_names)
|
20
|
+
SessionManager.load(".iterm-sessions").list
|
21
|
+
end
|
22
|
+
|
23
|
+
map(
|
24
|
+
"s" => "start",
|
25
|
+
"k" => "kill",
|
26
|
+
"l" => "ls",
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
class CLI < Thor
|
31
|
+
include ZshCompletion::Command
|
32
|
+
|
33
|
+
desc "list-sessions", "List name of all sessions in current terminal"
|
34
|
+
def list_sessions
|
35
|
+
puts Terminal::ListSessions.call.join("\n")
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "new-session COMMAND", "Create new session in current terminal"
|
39
|
+
option :name, aliases: :n
|
40
|
+
option :debug, type: :boolean
|
41
|
+
def new_session(*command)
|
42
|
+
Terminal::NewSession.call(command, name: options.name, debug: options.debug)
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "send-keys KEYS", "Send keys to session"
|
46
|
+
option :target, aliases: :t, required: true
|
47
|
+
def send_keys(*keys)
|
48
|
+
Terminal::SendKeys.call(keys, target: options.target)
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "sessions SUBCOMMAND ...ARGS", "Manage sessions by .iterm-sessions"
|
52
|
+
subcommand "sessions", SessionsCommand
|
53
|
+
|
54
|
+
map(
|
55
|
+
"l" => "list_sessions",
|
56
|
+
"n" => "new_session",
|
57
|
+
"k" => "send_keys",
|
58
|
+
"s" => "sessions",
|
59
|
+
)
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
module ITermCLI
|
4
|
+
class SessionManager
|
5
|
+
class Session
|
6
|
+
attr_accessor :name, :command, :kill
|
7
|
+
private :name=, :command=, :kill=
|
8
|
+
|
9
|
+
def initialize(attributes)
|
10
|
+
attributes.each do |k, v|
|
11
|
+
send("#{k}=", v)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.load(sessions_file)
|
17
|
+
unless File.exists?(sessions_file)
|
18
|
+
$stderr.puts "#{sessions_file} not found"
|
19
|
+
exit 1
|
20
|
+
end
|
21
|
+
sessions = YAML.load_file(sessions_file)
|
22
|
+
new(sessions)
|
23
|
+
end
|
24
|
+
|
25
|
+
attr_reader :sessions
|
26
|
+
|
27
|
+
def initialize(sessions)
|
28
|
+
@sessions = parse_sessions(sessions)
|
29
|
+
end
|
30
|
+
|
31
|
+
def start(names)
|
32
|
+
sessions_will_start = select_sessions_by_names(names)
|
33
|
+
existed = existed_session_names
|
34
|
+
sessions_will_start.reject!{|s| existed.include?(s.name) }
|
35
|
+
|
36
|
+
mutex = Mutex.new
|
37
|
+
sessions_will_start.map{|session|
|
38
|
+
Thread.new {
|
39
|
+
mutex.synchronize { $stdout.puts "Start #{session.name}" }
|
40
|
+
Terminal::NewSession.call([session.command], name: session.name)
|
41
|
+
}
|
42
|
+
}.each(&:join)
|
43
|
+
end
|
44
|
+
|
45
|
+
def kill(names)
|
46
|
+
sessions_will_kill = select_sessions_by_names(names)
|
47
|
+
existed = existed_session_names
|
48
|
+
sessions_will_kill.select!{|s| existed.include?(s.name) }
|
49
|
+
|
50
|
+
mutex = Mutex.new
|
51
|
+
sessions_will_kill.map{|session|
|
52
|
+
Thread.new {
|
53
|
+
mutex.synchronize { $stdout.puts "Kill #{session.name}" }
|
54
|
+
Terminal::SendKeys.call(session.kill.split(" "), target: session.name)
|
55
|
+
}
|
56
|
+
}.each(&:join)
|
57
|
+
end
|
58
|
+
|
59
|
+
def list
|
60
|
+
existed = existed_session_names
|
61
|
+
column_width = sessions.values.map{|s| s.name.length }.max
|
62
|
+
sessions.values.each do |session|
|
63
|
+
prefix = if existed.include?(session.name)
|
64
|
+
"*"
|
65
|
+
else
|
66
|
+
" "
|
67
|
+
end
|
68
|
+
puts [prefix, session.name.ljust(column_width), session.command].join(" ")
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
def select_sessions_by_names(names)
|
74
|
+
if names.empty?
|
75
|
+
sessions.values
|
76
|
+
else
|
77
|
+
r = []
|
78
|
+
names.each do |name|
|
79
|
+
s = sessions[name]
|
80
|
+
unless s
|
81
|
+
$stderr.puts "#{name} not defined"
|
82
|
+
exit 1
|
83
|
+
end
|
84
|
+
r << s
|
85
|
+
end
|
86
|
+
r
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def parse_sessions(sessions)
|
91
|
+
sessions.inject({}) do |h, (k, v)|
|
92
|
+
s = {name: k}
|
93
|
+
session = case v
|
94
|
+
when String
|
95
|
+
Session.new(name: k, command: v, kill: "C-c")
|
96
|
+
when Hash
|
97
|
+
Session.new(v.merge(name: k))
|
98
|
+
end
|
99
|
+
h[k] = session
|
100
|
+
h
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def existed_session_names
|
105
|
+
Terminal::ListSessions.call
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "open3"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
module ITermCLI
|
5
|
+
module Terminal
|
6
|
+
class Function
|
7
|
+
def self.call(*args)
|
8
|
+
new.call(*args)
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(*args)
|
12
|
+
raise NotImplementedError
|
13
|
+
end
|
14
|
+
|
15
|
+
def osascript(source, arg = {})
|
16
|
+
out, err, status = Open3.capture3("/usr/bin/osascript", "-l", "JavaScript", "-e", source, arg.to_json)
|
17
|
+
unless status.success?
|
18
|
+
$stderr.puts "osascript exited with #{status.to_i}"
|
19
|
+
$stderr.puts err
|
20
|
+
exit status.to_i
|
21
|
+
end
|
22
|
+
out
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ITermCLI
|
2
|
+
module Terminal
|
3
|
+
class ListSessions < Function
|
4
|
+
SOURCE = <<-JS
|
5
|
+
function run(argv) {
|
6
|
+
var iTerm = Application("iTerm2");
|
7
|
+
var window = iTerm.currentWindow();
|
8
|
+
var names = [];
|
9
|
+
var i, tab;
|
10
|
+
|
11
|
+
for (i = 0; i < window.tabs.length; i++) {
|
12
|
+
tab = window.tabs[i];
|
13
|
+
names.push(tab.currentSession().name());
|
14
|
+
}
|
15
|
+
|
16
|
+
return names.join("\\n");
|
17
|
+
}
|
18
|
+
JS
|
19
|
+
|
20
|
+
def call
|
21
|
+
osascript(SOURCE).split("\n")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require "shellwords"
|
2
|
+
module ITermCLI
|
3
|
+
module Terminal
|
4
|
+
class NewSession < Function
|
5
|
+
SOURCE = <<-JS
|
6
|
+
function run(argv) {
|
7
|
+
var options = JSON.parse(argv[0]);
|
8
|
+
var iTerm = Application("iTerm2");
|
9
|
+
var window = iTerm.currentWindow();
|
10
|
+
var tab = iTerm.createTab(window, {withProfile: "Default", command: options.command});
|
11
|
+
|
12
|
+
tab.currentSession().name = options.name;
|
13
|
+
}
|
14
|
+
JS
|
15
|
+
|
16
|
+
# command should be ["command", "arg"] or ["command arg"]
|
17
|
+
def call(command_and_args, options = {})
|
18
|
+
options = {name: nil, debug: false}.merge(options)
|
19
|
+
name = options[:name]
|
20
|
+
debug = options[:debug]
|
21
|
+
|
22
|
+
command = join_command(command_and_args)
|
23
|
+
executable = command.shellsplit.first
|
24
|
+
|
25
|
+
unless which(executable)
|
26
|
+
$stderr.puts "No such file or directory: #{executable}"
|
27
|
+
exit 1
|
28
|
+
end
|
29
|
+
|
30
|
+
name ||= executable.split("/").last
|
31
|
+
|
32
|
+
script_lines = []
|
33
|
+
script_lines.concat(set_env_lines)
|
34
|
+
script_lines << "cd #{Dir.pwd.shellescape}"
|
35
|
+
script_lines << command
|
36
|
+
|
37
|
+
if debug
|
38
|
+
puts script_lines
|
39
|
+
end
|
40
|
+
|
41
|
+
script_filename = write_script(script_lines.join("\n"))
|
42
|
+
osascript(SOURCE, command: "/bin/sh #{script_filename.shellescape}", name: name)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
def which(executable)
|
47
|
+
system("which", executable, out: "/dev/null", err: "/dev/null")
|
48
|
+
end
|
49
|
+
|
50
|
+
def join_command(command_and_args)
|
51
|
+
case command_and_args.size
|
52
|
+
when 0
|
53
|
+
ENV["SHELL"]
|
54
|
+
when 1
|
55
|
+
command_and_args[0]
|
56
|
+
else
|
57
|
+
command_and_args.shelljoin
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def set_env_lines
|
62
|
+
ENV.reject{|k, v| k == "_" }.map{|kv| "export " + kv.map(&:shellescape).join("=") }
|
63
|
+
end
|
64
|
+
|
65
|
+
def write_script(script)
|
66
|
+
filename = Dir.mktmpdir("iterm-new-session") + "/iterm-new-session.sh"
|
67
|
+
open(filename, "w"){|f| f.write(script) }
|
68
|
+
filename
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module ITermCLI
|
2
|
+
module Terminal
|
3
|
+
class SendKeys < Function
|
4
|
+
SOURCE = <<-JS
|
5
|
+
function run(argv) {
|
6
|
+
var options = JSON.parse(argv[0]);
|
7
|
+
var iTerm = Application("iTerm2");
|
8
|
+
var window = iTerm.currentWindow();
|
9
|
+
var i, session;
|
10
|
+
|
11
|
+
for (i = 0; i < window.tabs.length; i++) {
|
12
|
+
session = window.tabs[i].currentSession();
|
13
|
+
if (session.name() === options.target) {
|
14
|
+
session.write({text: options.text});
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
JS
|
21
|
+
|
22
|
+
def call(keys, options = {})
|
23
|
+
options = {target: nil}.merge(options)
|
24
|
+
target = options[:target]
|
25
|
+
|
26
|
+
text = keys.map{|t|
|
27
|
+
case t
|
28
|
+
when /\AC-(.)$\z/
|
29
|
+
($1.ord & 0b00011111).chr
|
30
|
+
when "Enter"
|
31
|
+
"\n"
|
32
|
+
else
|
33
|
+
t
|
34
|
+
end
|
35
|
+
}.join(" ")
|
36
|
+
|
37
|
+
osascript(SOURCE, target: target, text: text)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module ITermCLI
|
2
|
+
module Terminal
|
3
|
+
autoload :Function, "iterm_cli/terminal/function"
|
4
|
+
autoload :ListSessions, "iterm_cli/terminal/list_sessions"
|
5
|
+
autoload :NewSession, "iterm_cli/terminal/new_session"
|
6
|
+
autoload :SendKeys, "iterm_cli/terminal/send_keys"
|
7
|
+
end
|
8
|
+
end
|
data/lib/iterm_cli.rb
ADDED
metadata
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: iterm_cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- labocho
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.19.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.19.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor-zsh_completion
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.10'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Command line interface for iTerm2
|
84
|
+
email:
|
85
|
+
- labocho@penguinlab.jp
|
86
|
+
executables:
|
87
|
+
- iterm
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".travis.yml"
|
94
|
+
- CHANGELOG.md
|
95
|
+
- CODE_OF_CONDUCT.md
|
96
|
+
- Gemfile
|
97
|
+
- LICENSE.txt
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- bin/console
|
101
|
+
- bin/setup
|
102
|
+
- exe/iterm
|
103
|
+
- iterm_cli.gemspec
|
104
|
+
- lib/iterm_cli.rb
|
105
|
+
- lib/iterm_cli/cli.rb
|
106
|
+
- lib/iterm_cli/session_manager.rb
|
107
|
+
- lib/iterm_cli/terminal.rb
|
108
|
+
- lib/iterm_cli/terminal/function.rb
|
109
|
+
- lib/iterm_cli/terminal/list_sessions.rb
|
110
|
+
- lib/iterm_cli/terminal/new_session.rb
|
111
|
+
- lib/iterm_cli/terminal/send_keys.rb
|
112
|
+
- lib/iterm_cli/version.rb
|
113
|
+
homepage: https://github.com/labocho/iterm_cli
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
metadata: {}
|
117
|
+
post_install_message:
|
118
|
+
rdoc_options: []
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
requirements: []
|
132
|
+
rubyforge_project:
|
133
|
+
rubygems_version: 2.5.1
|
134
|
+
signing_key:
|
135
|
+
specification_version: 4
|
136
|
+
summary: Command line interface for iTerm2
|
137
|
+
test_files: []
|