iterm_cli 1.0.3 → 1.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ef00a0f6bc21b02fcfffffda443665121e392889
4
- data.tar.gz: c39b513018eceeb2ae7f672fe71c7769c9388883
2
+ SHA256:
3
+ metadata.gz: 25cebfc56bdee4afdfa5ac2594068dc35cc10ab220ed718f89576bb3d74dca40
4
+ data.tar.gz: 43f921ebf4da8de3f55f4e6321878ec2817f492e528e7522234134098d159500
5
5
  SHA512:
6
- metadata.gz: 684dc54eb10dfb22259fdfcabee8e608bab5081d03fde55f921061ecc030a9b4b45827cb7f4a9ee5c358086c25fbea2ca76e137d889c6c7e4354ee798f0e6387
7
- data.tar.gz: b9343055ffb8a5efef3bdf2ef2f93ee1be4d3185bb1a03a1931ea3f57d75cd97a217690fdcf4b6638744116653169b3a284336f66f8efa777a8fc5b52af3da4d
6
+ metadata.gz: 763c71eef7da2f6658382203edb953954dfcd64cb94dcf70807e6a9b1262ea0750763414daa130646e5e85aa26e182cef5cdee354e8b79e421004001ff7209a3
7
+ data.tar.gz: 3a1e2b3a76a1e02f4b23fb9612029d555b40a7f0716aa8e4da631e0a5acc724a6aed153c566476a6aca1e16e89cbc3d9cedf932ca9b32ff61df14b61d2348e74
data/.rubocop.yml ADDED
@@ -0,0 +1,129 @@
1
+ AllCops:
2
+ Exclude:
3
+ - bin/*
4
+ - node_modules/**/*
5
+
6
+ Layout/CaseIndentation:
7
+ EnforcedStyle: end
8
+
9
+ Layout/EndAlignment:
10
+ EnforcedStyleAlignWith: variable
11
+
12
+ Layout/EmptyLinesAroundAccessModifier:
13
+ EnforcedStyle: only_before
14
+
15
+ Layout/SpaceInLambdaLiteral:
16
+ EnforcedStyle: require_space
17
+
18
+ Layout/SpaceInsideBlockBraces:
19
+ SpaceBeforeBlockParameters: false
20
+
21
+ Layout/SpaceInsideHashLiteralBraces:
22
+ EnforcedStyle: no_space
23
+
24
+ Metrics/AbcSize:
25
+ Enabled: false
26
+
27
+ Metrics/BlockLength:
28
+ Enabled: false
29
+
30
+ Metrics/ClassLength:
31
+ Enabled: false
32
+
33
+ Metrics/CyclomaticComplexity:
34
+ Enabled: false
35
+
36
+ Metrics/LineLength:
37
+ Enabled: false
38
+
39
+ Metrics/MethodLength:
40
+ Enabled: false
41
+
42
+ Metrics/ModuleLength:
43
+ Enabled: false
44
+
45
+ Metrics/PerceivedComplexity:
46
+ Enabled: false
47
+
48
+ Naming/HeredocDelimiterNaming:
49
+ Enabled: false
50
+
51
+ Naming/PredicateName:
52
+ Enabled: false
53
+
54
+ Naming/UncommunicativeMethodParamName:
55
+ Enabled: false
56
+
57
+ Style/Alias:
58
+ EnforcedStyle: prefer_alias_method
59
+
60
+ Style/AsciiComments:
61
+ Enabled: false
62
+
63
+ Style/BlockDelimiters:
64
+ Enabled: false
65
+
66
+ Style/Documentation:
67
+ Enabled: false
68
+
69
+ Style/EmptyCaseCondition:
70
+ Enabled: false
71
+
72
+ Style/EmptyMethod:
73
+ EnforcedStyle: expanded
74
+
75
+ Style/FrozenStringLiteralComment:
76
+ Enabled: false
77
+
78
+ Style/HashSyntax:
79
+ Exclude:
80
+ - Rakefile
81
+ - "**/*.rake"
82
+
83
+ Style/Lambda:
84
+ EnforcedStyle: literal
85
+
86
+ Style/IfUnlessModifier:
87
+ Enabled: false
88
+
89
+ Style/MultilineBlockChain:
90
+ Enabled: false
91
+
92
+ Style/NumericLiterals:
93
+ Enabled: false
94
+
95
+ Style/NumericPredicate:
96
+ Enabled: false
97
+
98
+ Style/PercentLiteralDelimiters:
99
+ PreferredDelimiters:
100
+ '%i': '()'
101
+ '%w': '()'
102
+ '%r': '()'
103
+
104
+ Style/PerlBackrefs:
105
+ Enabled: false
106
+
107
+ Style/SpecialGlobalVars:
108
+ Enabled: false
109
+
110
+ Style/StringLiterals:
111
+ EnforcedStyle: double_quotes
112
+
113
+ Style/StringLiteralsInInterpolation:
114
+ EnforcedStyle: double_quotes
115
+
116
+ Style/SymbolArray:
117
+ Enabled: false
118
+
119
+ Style/TrailingCommaInArguments:
120
+ EnforcedStyleForMultiline: consistent_comma
121
+
122
+ Style/TrailingCommaInArrayLiteral:
123
+ EnforcedStyleForMultiline: consistent_comma
124
+
125
+ Style/TrailingCommaInHashLiteral:
126
+ EnforcedStyleForMultiline: consistent_comma
127
+
128
+ Style/ZeroLengthPredicate:
129
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
- ## v1.0.3 - 2017-04-28
3
+ ## v1.0.4 (2019-11-27)
4
+
5
+ - Add `-l` option to `$SHELL` when `iterm new-session` is invoked with no argument.
6
+
7
+ ## v1.0.3 (2017-04-28)
4
8
 
5
9
  - First release.
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in iterm_cli.gemspec
4
4
  gemspec
data/README.md CHANGED
@@ -9,6 +9,10 @@ iTerm2 Build 3.0.4 or later.
9
9
 
10
10
  ## Installation
11
11
 
12
+ $ gem install iterm_cli
13
+
14
+ Or
15
+
12
16
  $ git clone https://github.com/labocho/iterm_cli
13
17
  $ cd iterm_cli
14
18
  $ rake install
data/bin/rubocop ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rubocop' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rubocop", "rubocop")
data/iterm_cli.gemspec CHANGED
@@ -1,7 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path("lib", __dir__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'iterm_cli/version'
3
+ require "iterm_cli/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = "iterm_cli"
@@ -9,14 +8,14 @@ Gem::Specification.new do |spec|
9
8
  spec.authors = ["labocho"]
10
9
  spec.email = ["labocho@penguinlab.jp"]
11
10
 
12
- spec.summary = %q{Command line interface for iTerm2}
13
- spec.description = %q{Command line interface for iTerm2}
11
+ spec.summary = "Command line interface for iTerm2"
12
+ spec.description = "Command line interface for iTerm2"
14
13
  spec.homepage = "https://github.com/labocho/iterm_cli"
15
14
  spec.license = "MIT"
16
15
 
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
18
17
  spec.bindir = "exe"
19
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.executables = spec.files.grep(%r(^exe/)) {|f| File.basename(f) }
20
19
  spec.require_paths = ["lib"]
21
20
 
22
21
  spec.add_dependency "thor", "~> 0.19.1"
@@ -25,4 +24,5 @@ Gem::Specification.new do |spec|
25
24
  spec.add_development_dependency "bundler", "~> 1.10"
26
25
  spec.add_development_dependency "rake", "~> 10.0"
27
26
  spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "rubocop"
28
28
  end
data/lib/iterm_cli/cli.rb CHANGED
@@ -16,7 +16,7 @@ module ITermCLI
16
16
  end
17
17
 
18
18
  desc "ls", "List sessions"
19
- def ls(*session_names)
19
+ def ls
20
20
  SessionManager.load(".iterm-sessions").list
21
21
  end
22
22
 
@@ -14,8 +14,8 @@ module ITermCLI
14
14
  end
15
15
 
16
16
  def self.load(sessions_file)
17
- unless File.exists?(sessions_file)
18
- $stderr.puts "#{sessions_file} not found"
17
+ unless File.exist?(sessions_file)
18
+ warn "#{sessions_file} not found"
19
19
  exit 1
20
20
  end
21
21
  sessions = YAML.load_file(sessions_file)
@@ -31,10 +31,10 @@ module ITermCLI
31
31
  def start(names)
32
32
  sessions_will_start = select_sessions_by_names(names)
33
33
  existed = existed_session_names
34
- sessions_will_start.reject!{|s| existed.include?(s.name) }
34
+ sessions_will_start.reject! {|s| existed.include?(s.name) }
35
35
 
36
36
  mutex = Mutex.new
37
- sessions_will_start.map{|session|
37
+ sessions_will_start.map {|session|
38
38
  Thread.new {
39
39
  mutex.synchronize { $stdout.puts "Start #{session.name}" }
40
40
  Terminal::NewSession.call([session.command], name: session.name)
@@ -45,10 +45,10 @@ module ITermCLI
45
45
  def kill(names)
46
46
  sessions_will_kill = select_sessions_by_names(names)
47
47
  existed = existed_session_names
48
- sessions_will_kill.select!{|s| existed.include?(s.name) }
48
+ sessions_will_kill.select! {|s| existed.include?(s.name) }
49
49
 
50
50
  mutex = Mutex.new
51
- sessions_will_kill.map{|session|
51
+ sessions_will_kill.map {|session|
52
52
  Thread.new {
53
53
  mutex.synchronize { $stdout.puts "Kill #{session.name}" }
54
54
  Terminal::SendKeys.call(session.kill.split(" "), target: session.name)
@@ -58,7 +58,7 @@ module ITermCLI
58
58
 
59
59
  def list
60
60
  existed = existed_session_names
61
- column_width = sessions.values.map{|s| s.name.length }.max
61
+ column_width = sessions.values.map {|s| s.name.length }.max
62
62
  sessions.values.each do |session|
63
63
  prefix = if existed.include?(session.name)
64
64
  "*"
@@ -78,7 +78,7 @@ module ITermCLI
78
78
  names.each do |name|
79
79
  s = sessions[name]
80
80
  unless s
81
- $stderr.puts "#{name} not defined"
81
+ warn "#{name} not defined"
82
82
  exit 1
83
83
  end
84
84
  r << s
@@ -88,8 +88,7 @@ module ITermCLI
88
88
  end
89
89
 
90
90
  def parse_sessions(sessions)
91
- sessions.inject({}) do |h, (k, v)|
92
- s = {name: k}
91
+ sessions.each_with_object({}) do |(k, v), h|
93
92
  session = case v
94
93
  when String
95
94
  Session.new(name: k, command: v, kill: "C-c")
@@ -97,7 +96,6 @@ module ITermCLI
97
96
  Session.new(v.merge(name: k))
98
97
  end
99
98
  h[k] = session
100
- h
101
99
  end
102
100
  end
103
101
 
@@ -8,15 +8,15 @@ module ITermCLI
8
8
  new.call(*args)
9
9
  end
10
10
 
11
- def call(*args)
11
+ def call(*_args)
12
12
  raise NotImplementedError
13
13
  end
14
14
 
15
15
  def osascript(source, arg = {})
16
16
  out, err, status = Open3.capture3("/usr/bin/osascript", "-l", "JavaScript", "-e", source, arg.to_json)
17
17
  unless status.success?
18
- $stderr.puts "osascript exited with #{status.to_i}"
19
- $stderr.puts err
18
+ warn "osascript exited with #{status.to_i}"
19
+ warn err
20
20
  exit status.to_i
21
21
  end
22
22
  out
@@ -1,7 +1,7 @@
1
1
  module ITermCLI
2
2
  module Terminal
3
3
  class ListSessions < Function
4
- SOURCE = <<-JS
4
+ SOURCE = <<-JS.freeze
5
5
  function run(argv) {
6
6
  var iTerm = Application("iTerm2");
7
7
  var window = iTerm.currentWindow();
@@ -2,7 +2,7 @@ require "shellwords"
2
2
  module ITermCLI
3
3
  module Terminal
4
4
  class NewSession < Function
5
- SOURCE = <<-JS
5
+ SOURCE = <<-JS.freeze
6
6
  function run(argv) {
7
7
  var options = JSON.parse(argv[0]);
8
8
  var iTerm = Application("iTerm2");
@@ -23,7 +23,7 @@ module ITermCLI
23
23
  executable = command.shellsplit.first
24
24
 
25
25
  unless which(executable)
26
- $stderr.puts "No such file or directory: #{executable}"
26
+ warn "No such file or directory: #{executable}"
27
27
  exit 1
28
28
  end
29
29
 
@@ -50,7 +50,7 @@ module ITermCLI
50
50
  def join_command(command_and_args)
51
51
  case command_and_args.size
52
52
  when 0
53
- ENV["SHELL"]
53
+ ENV["SHELL"] + " -l"
54
54
  when 1
55
55
  command_and_args[0]
56
56
  else
@@ -59,12 +59,12 @@ module ITermCLI
59
59
  end
60
60
 
61
61
  def set_env_lines
62
- ENV.reject{|k, v| k == "_" }.map{|kv| "export " + kv.map(&:shellescape).join("=") }
62
+ ENV.reject {|k, _v| k == "_" }.map {|kv| "export " + kv.map(&:shellescape).join("=") }
63
63
  end
64
64
 
65
65
  def write_script(script)
66
66
  filename = Dir.mktmpdir("iterm-new-session") + "/iterm-new-session.sh"
67
- open(filename, "w"){|f| f.write(script) }
67
+ File.write(filename, script)
68
68
  filename
69
69
  end
70
70
  end
@@ -1,7 +1,7 @@
1
1
  module ITermCLI
2
2
  module Terminal
3
3
  class SendKeys < Function
4
- SOURCE = <<-JS
4
+ SOURCE = <<-JS.freeze
5
5
  function run(argv) {
6
6
  var options = JSON.parse(argv[0]);
7
7
  var iTerm = Application("iTerm2");
@@ -23,7 +23,7 @@ module ITermCLI
23
23
  options = {target: nil}.merge(options)
24
24
  target = options[:target]
25
25
 
26
- text = keys.map{|t|
26
+ text = keys.map {|t|
27
27
  case t
28
28
  when /\AC-(.)$\z/
29
29
  ($1.ord & 0b00011111).chr
@@ -1,3 +1,3 @@
1
1
  module ITermCLI
2
- VERSION = "1.0.3"
2
+ VERSION = "1.0.4".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iterm_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - labocho
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-28 00:00:00.000000000 Z
11
+ date: 2019-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: Command line interface for iTerm2
84
98
  email:
85
99
  - labocho@penguinlab.jp
@@ -90,6 +104,7 @@ extra_rdoc_files: []
90
104
  files:
91
105
  - ".gitignore"
92
106
  - ".rspec"
107
+ - ".rubocop.yml"
93
108
  - ".travis.yml"
94
109
  - CHANGELOG.md
95
110
  - CODE_OF_CONDUCT.md
@@ -98,6 +113,7 @@ files:
98
113
  - README.md
99
114
  - Rakefile
100
115
  - bin/console
116
+ - bin/rubocop
101
117
  - bin/setup
102
118
  - exe/iterm
103
119
  - iterm_cli.gemspec
@@ -129,8 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
145
  - !ruby/object:Gem::Version
130
146
  version: '0'
131
147
  requirements: []
132
- rubyforge_project:
133
- rubygems_version: 2.5.1
148
+ rubygems_version: 3.0.3
134
149
  signing_key:
135
150
  specification_version: 4
136
151
  summary: Command line interface for iTerm2