hiiro 0.1.124 → 0.1.126

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
2
  SHA256:
3
- metadata.gz: 07e567369471f9f5c5aacb65fe7e7a29df6f7125cca138a2788567597abd1a2e
4
- data.tar.gz: c6bc9ae5a1d181e15e255ce831ee13b52ef277cfc9e4dd06e35330c5b368207f
3
+ metadata.gz: 0f321444255d4b160d34528a803115bb6f9197c790fb719bf135b45ffcdd8125
4
+ data.tar.gz: ca269e97bfede7c97d19e01c5e73706d0b2abf63af0aa93272cba1e8b130ed2a
5
5
  SHA512:
6
- metadata.gz: 8ee763ca17e6f61efc9ca7e9e5eedb8ceec4609936c2a11c850c5efd63ba7297f1112d852e07f68ab52e6c79c89c6279eb677c385ff4427285af9e4f2d4e446d
7
- data.tar.gz: 4f4c032a247b5fb4bdb81420cd92e98bea0cac9853270e05eaa57050b73e7f0ef68a379f3ac758133c4ca9de42d3021b3dce10f93042530bd268aa87b4563bbf
6
+ metadata.gz: 7716e761376c53d15e0519ccc8eea8ebadd3a62004a634f66e275ac56e73f56b7051d12774a962f95f43ffe509c6e6912b258e022fcf06ed21689217053c8404
7
+ data.tar.gz: c6f00c587b31ebc02d5abf112c55cc0635d05b5125162af68d1d8e998e5f63f9e4d6130b5c6d821b7e36ed08d45b8da78123f789153e34ca60ae4af5ed479030
data/bin/h-bin ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'hiiro'
4
+
5
+ Hiiro.run do
6
+ add_subcmd(:list) do |*subcmd_names|
7
+ patterns = subcmd_names.flatten.compact
8
+ .map { |sc|
9
+ sc.sub(/^(h-)?/, '{h-,}')
10
+ }
11
+
12
+ all_bins = Hiiro::Bins.glob(patterns)
13
+ bins = all_bins.each_with_object({}) { |bin, h|
14
+ basename = File.basename(bin)
15
+ next if h.key?(basename)
16
+
17
+ h[basename] = bin
18
+ }.values
19
+
20
+ puts bins
21
+ end
22
+
23
+ add_subcmd(:edit) do |*subcmd_names|
24
+ patterns = subcmd_names.flatten.compact.map { |sc|
25
+ sc.sub(/^(h-)?/, '{h-,}')
26
+ }
27
+
28
+ all_bins = Hiiro::Bins.glob(patterns)
29
+ bins = all_bins.each_with_object({}) { |bin, h|
30
+ basename = File.basename(bin)
31
+ next if h.key?(basename)
32
+
33
+ h[basename] = bin
34
+ }.values
35
+
36
+ edit_files(*bins)
37
+ end
38
+ end
data/lib/hiiro/bins.rb ADDED
@@ -0,0 +1,19 @@
1
+ class Hiiro
2
+ class Bins
3
+ PATH = ENV['PATH']
4
+
5
+ def self.path = PATH
6
+ def self.paths = path.split(?:).map(&:strip).uniq
7
+
8
+ def self.glob(*names)
9
+ path_glob = [?{, paths.join(?,), ?}].join
10
+ name_glob = [?{, names.flatten.compact.join(?,), ?}].join
11
+
12
+ Dir[File.join(path_glob, name_glob)].select(&File.method(:executable?))
13
+ end
14
+
15
+ def self.all
16
+ Dir[glob('*')].select(&File.method(:executable?))
17
+ end
18
+ end
19
+ end
data/lib/hiiro/tmux.rb CHANGED
@@ -80,7 +80,7 @@ class Hiiro
80
80
  # Session methods
81
81
 
82
82
  def session_exists?(name)
83
- run_success?('has-session', '-t', name)
83
+ sessions.any?{|session| session.name == name }
84
84
  end
85
85
 
86
86
  def open_session(name, **opts)
data/lib/hiiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.124"
2
+ VERSION = "0.1.126"
3
3
  end
data/lib/hiiro.rb CHANGED
@@ -4,6 +4,7 @@ require "shellwords"
4
4
  require "pry"
5
5
 
6
6
  require_relative "hiiro/version"
7
+ require_relative "hiiro/bins"
7
8
  require_relative "hiiro/matcher"
8
9
  require_relative "hiiro/git"
9
10
  require_relative "hiiro/options"
@@ -132,6 +133,20 @@ class Hiiro
132
133
  task_manager&.tasks
133
134
  end
134
135
 
136
+ def editor
137
+ editors = Bins.glob(%w[nvim vim vi]).find(&File.method(:executable?))
138
+
139
+ ENV['EDITOR'] || editors.first
140
+ end
141
+
142
+ def edit_files(*files)
143
+ if editor.match?(/vim/i)
144
+ system(editor, '-O', *files)
145
+ else
146
+ system(editor, *files)
147
+ end
148
+ end
149
+
135
150
  def tmux_client
136
151
  @tmux_client ||= Tmux.client!(self)
137
152
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiiro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.124
4
+ version: 0.1.126
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota
@@ -84,6 +84,7 @@ files:
84
84
  - TODO.md
85
85
  - bin/h
86
86
  - bin/h-app
87
+ - bin/h-bin
87
88
  - bin/h-branch
88
89
  - bin/h-buffer
89
90
  - bin/h-claude
@@ -111,6 +112,7 @@ files:
111
112
  - exe/hiiro
112
113
  - hiiro.gemspec
113
114
  - lib/hiiro.rb
115
+ - lib/hiiro/bins.rb
114
116
  - lib/hiiro/fuzzyfind.rb
115
117
  - lib/hiiro/git.rb
116
118
  - lib/hiiro/git/branch.rb