hiiro 0.1.86 → 0.1.87

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: 2da3861933a1b2b03e5ff7cd9fa87d700e7f3f1ed8e6eb62463ec93c783e2a86
4
- data.tar.gz: 9c5957829cae479530f68cccae440bc683285a93e1695db75c4a44dfa1a02503
3
+ metadata.gz: ce90e3d37e2dfb575b7a30f2070c605e377146073fe32f715768383b907290f4
4
+ data.tar.gz: a700aaee8c6b5c0eadfe6fe694df2a97291b38aa289c6c5dfce931e8ce1df39d
5
5
  SHA512:
6
- metadata.gz: 6c0c41355a0c33056574f1e4c61d937087e7b8fedb1db2fe864f41f571264c44c8c7c46af14b4e238d17f202f061f599fb982fa7fdcfddc7829051802462e7f8
7
- data.tar.gz: 07a5888842492bf0aa9b9ed5444b9f9b12bb15ea14615b70eaeb44b4c0e41d9319e1ffdbab80eba422108a91cb68dfb5c0c20edc9f76500364eaf67ee5671d25
6
+ metadata.gz: 398be942e72ed10cd94becb6626d2c29bedd8554647e792b05cccea5098964085995a7eae2ebf0c15a3d5bacac73766884fcdb9ed8499d6546e3fb71ae48d59d
7
+ data.tar.gz: d6f3682431737967af381781a888d028b5b2fe13617d34eba984bebed53e5c4ffcbe41c9c79d72eba70aec3cfb8400f8185db5cf678953475896a5f96948922e
data/CLAUDE.md CHANGED
@@ -154,7 +154,7 @@ Main entry point with class methods:
154
154
 
155
155
  Instance methods available in subcommand blocks:
156
156
  - `git` - Returns `Hiiro::Git` instance for git operations
157
- - `sk(lines)` - Interactive selection via skim
157
+ - `fuzzyfind(lines)` - Interactive selection via skim
158
158
  - `pins` - Key-value storage per command
159
159
  - `todo_manager` - Todo item management
160
160
  - `history` - Command history tracking
@@ -193,15 +193,15 @@ git.move_worktree(from, to) # Rename worktree
193
193
  git.current_pr # Get current PR info
194
194
  ```
195
195
 
196
- ### Hiiro::Sk (lib/hiiro/sk.rb)
196
+ ### Hiiro::Fuzzyfind (lib/hiiro/fuzzyfind.rb)
197
197
 
198
- Integration with `sk` (skim) fuzzy finder:
198
+ Integration with `sk` (skim) or `fzf` fuzzy finders:
199
199
 
200
200
  ```ruby
201
- selected = Hiiro::Sk.select(["option1", "option2", "option3"])
201
+ selected = Hiiro::Fuzzyfind.select(["option1", "option2", "option3"])
202
202
  # Returns selected string or nil if cancelled
203
203
 
204
- value = Hiiro::Sk.map_select({ "Display 1" => "value1", "Display 2" => "value2" })
204
+ value = Hiiro::Fuzzyfind.map_select({ "Display 1" => "value1", "Display 2" => "value2" })
205
205
  # Shows keys, returns corresponding value
206
206
  ```
207
207
 
@@ -235,7 +235,7 @@ History.by_session("work") # Filter by tmux session
235
235
  - `bin/h-*` - External subcommands (tmux wrappers, video operations)
236
236
  - `plugins/*.rb` - Reusable plugin modules (Pins, Project, Task, Tmux, Notify)
237
237
  - `lib/hiiro.rb` - Main Hiiro class and Runners
238
- - `lib/hiiro/*.rb` - Supporting classes (Git, PrefixMatcher, Sk, Todo, History)
238
+ - `lib/hiiro/*.rb` - Supporting classes (Git, PrefixMatcher, Fuzzyfind, Todo, History)
239
239
 
240
240
  ## External Dependencies
241
241
 
data/README.md CHANGED
@@ -36,7 +36,7 @@ Ensure `~/bin` is in your `$PATH`.
36
36
  brew install terminal-notifier
37
37
 
38
38
  # For fuzzy-finder
39
- brew install sk
39
+ brew install sk # (or fzf)
40
40
  ```
41
41
 
42
42
  ## Quick Start
data/bin/h-branch CHANGED
@@ -14,18 +14,6 @@ class BranchManager
14
14
  @hiiro = hiiro
15
15
  end
16
16
 
17
- def help
18
- puts "Usage: h branch <subcommand> [args]"
19
- puts
20
- puts "Subcommands:"
21
- puts " save Record current branch for this task"
22
- puts " history List branch history (oldest to newest)"
23
- puts " history --worktree=X Filter by worktree"
24
- puts " history --task=X Filter by task"
25
- puts " history --session=X Filter by tmux session"
26
- puts " current Show current branch info"
27
- end
28
-
29
17
  def save
30
18
  branch_name = current_branch
31
19
  unless branch_name
@@ -62,35 +50,6 @@ class BranchManager
62
50
  true
63
51
  end
64
52
 
65
- def history(args = [])
66
- filters = parse_filters(args)
67
- data = load_data
68
- branches = data['branches'] || []
69
-
70
- if branches.empty?
71
- puts "No branches recorded."
72
- puts "Use 'h branch save' to record the current branch."
73
- return
74
- end
75
-
76
- # Apply filters
77
- branches = filter_entries(branches, filters)
78
-
79
- if branches.empty?
80
- puts "No branches match the given filters."
81
- return
82
- end
83
-
84
- # Sort by created_at (oldest first)
85
- branches = branches.sort_by { |b| b['created_at'] || '' }
86
-
87
- puts "Branch history (oldest to newest):"
88
- puts
89
- branches.each_with_index do |branch, idx|
90
- puts format_entry(branch, idx + 1)
91
- end
92
- end
93
-
94
53
  def current
95
54
  branch_name = current_branch
96
55
  unless branch_name
@@ -132,48 +91,6 @@ class BranchManager
132
91
  }
133
92
  end
134
93
 
135
- def parse_filters(args)
136
- filters = {}
137
- args.each do |arg|
138
- case arg
139
- when /^--worktree=(.+)$/
140
- filters[:worktree] = $1
141
- when /^--task=(.+)$/
142
- filters[:task] = $1
143
- when /^--session=(.+)$/
144
- filters[:session] = $1
145
- when /^-w(.+)$/
146
- filters[:worktree] = $1
147
- when /^-t(.+)$/
148
- filters[:task] = $1
149
- when /^-s(.+)$/
150
- filters[:session] = $1
151
- end
152
- end
153
- filters
154
- end
155
-
156
- def filter_entries(entries, filters)
157
- entries.select do |entry|
158
- next false if filters[:worktree] && !entry['worktree']&.include?(filters[:worktree])
159
- next false if filters[:task] && !entry['task']&.include?(filters[:task])
160
- next false if filters[:session] && entry.dig('tmux', 'session') != filters[:session]
161
- true
162
- end
163
- end
164
-
165
- def format_entry(entry, num)
166
- lines = []
167
- lines << "#{num}. #{entry['name']}"
168
- lines << " Task: #{entry['task'] || '(none)'}"
169
- lines << " Worktree: #{entry['worktree'] || '(none)'}"
170
- if entry['tmux']
171
- lines << " Tmux: #{entry['tmux']['session']}/#{entry['tmux']['window']}"
172
- end
173
- lines << " Created: #{entry['created_at']}"
174
- lines.join("\n")
175
- end
176
-
177
94
  def show_entry(entry)
178
95
  puts " Branch: #{entry[:name]}"
179
96
  puts " Task: #{entry[:task] || '(none)'}"
@@ -204,8 +121,8 @@ manager = BranchManager.new(hiiro)
204
121
 
205
122
  hiiro.add_subcmd(:edit) { system(ENV['EDITOR'] || 'nvim', __FILE__) }
206
123
  hiiro.add_subcmd(:save) { manager.save }
207
- hiiro.add_subcmd(:history) { |*args| manager.history(args) }
208
- hiiro.add_subcmd(:current) { manager.current }
124
+ hiiro.add_subcmd(:current) { print `git branch --show-current` }
125
+ hiiro.add_subcmd(:info) { manager.current }
209
126
  hiiro.add_subcmd(:select) do |*args|
210
127
  branches = hiiro.git.branches(sort_by: 'authordate', ignore_case: true)
211
128
 
@@ -341,6 +258,36 @@ hiiro.add_subcmd(:diff) { |*args|
341
258
  system('git', 'log', '--oneline', '--decorate', range)
342
259
  }
343
260
 
261
+ hiiro.add_subcmd(:changed) { |*args|
262
+ show_all = args.delete('-a') || args.delete('--all')
263
+ upstream = args.first
264
+
265
+ upstream ||= %w[origin/master master origin/main main].find { |ref|
266
+ system("git rev-parse --verify #{ref} >/dev/null 2>&1")
267
+ }
268
+
269
+ unless upstream
270
+ puts "Cannot find master or origin/master"
271
+ next
272
+ end
273
+
274
+ forkpoint = `git merge-base --fork-point #{upstream} HEAD 2>/dev/null`.strip
275
+ if forkpoint.empty?
276
+ forkpoint = `git merge-base #{upstream} HEAD 2>/dev/null`.strip
277
+ end
278
+
279
+ if forkpoint.empty?
280
+ puts "Could not find fork point"
281
+ next
282
+ end
283
+
284
+ if show_all
285
+ system('git', 'diff', '--name-only', "#{forkpoint}...HEAD")
286
+ else
287
+ system('git', 'diff', '--name-only', '--relative', "#{forkpoint}...HEAD")
288
+ end
289
+ }
290
+
344
291
  hiiro.add_subcmd(:ahead) { |*args|
345
292
  case args.length
346
293
  when 0
@@ -375,6 +322,115 @@ hiiro.add_subcmd(:behind) { |*args|
375
322
  puts "#{branch} is #{count} commit(s) behind #{behind_of}"
376
323
  }
377
324
 
325
+ hiiro.add_subcmd(:log) { |upstream = nil|
326
+ upstream ||= %w[origin/master master origin/main main].find { |ref|
327
+ system("git rev-parse --verify #{ref} >/dev/null 2>&1")
328
+ }
329
+
330
+ unless upstream
331
+ puts "Cannot find master or origin/master"
332
+ next
333
+ end
334
+
335
+ forkpoint = `git merge-base --fork-point #{upstream} HEAD 2>/dev/null`.strip
336
+ if forkpoint.empty?
337
+ forkpoint = `git merge-base #{upstream} HEAD 2>/dev/null`.strip
338
+ end
339
+
340
+ if forkpoint.empty?
341
+ puts "Could not find fork point"
342
+ next
343
+ end
344
+
345
+ system('git', 'log', '--oneline', '--decorate', "#{forkpoint}..HEAD")
346
+ }
347
+
348
+ hiiro.add_subcmd(:forkpoint) { |upstream = nil, branch = nil|
349
+ branch ||= 'HEAD'
350
+ upstream ||= %w[origin/master master origin/main main].find { |ref|
351
+ system("git rev-parse --verify #{ref} >/dev/null 2>&1")
352
+ }
353
+
354
+ unless upstream
355
+ puts "Cannot find master or origin/master"
356
+ next
357
+ end
358
+
359
+ forkpoint = `git merge-base --fork-point #{upstream} #{branch} 2>/dev/null`.strip
360
+
361
+ if forkpoint.empty?
362
+ # Fallback to regular merge-base if fork-point fails
363
+ forkpoint = `git merge-base #{upstream} #{branch} 2>/dev/null`.strip
364
+ end
365
+
366
+ if forkpoint.empty?
367
+ puts "Could not find fork point between #{upstream} and #{branch}"
368
+ else
369
+ puts forkpoint
370
+ end
371
+ }
372
+
373
+ hiiro.add_subcmd(:changed) { |*args|
374
+ show_all = args.delete('-a') || args.delete('--all')
375
+ upstream = args.first
376
+
377
+ upstream ||= %w[origin/master master origin/main main].find { |ref|
378
+ system("git rev-parse --verify #{ref} >/dev/null 2>&1")
379
+ }
380
+
381
+ unless upstream
382
+ puts "Cannot find master or origin/master"
383
+ next
384
+ end
385
+
386
+ forkpoint = `git merge-base --fork-point #{upstream} HEAD 2>/dev/null`.strip
387
+ if forkpoint.empty?
388
+ forkpoint = `git merge-base #{upstream} HEAD 2>/dev/null`.strip
389
+ end
390
+
391
+ if forkpoint.empty?
392
+ puts "Could not find fork point"
393
+ next
394
+ end
395
+
396
+ if show_all
397
+ system('git', 'diff', '--name-only', "#{forkpoint}...HEAD")
398
+ else
399
+ system('git', 'diff', '--name-only', '--relative', "#{forkpoint}...HEAD")
400
+ end
401
+ }
402
+
403
+
404
+ hiiro.add_subcmd(:changed) { |*args|
405
+ show_all = args.delete('-a') || args.delete('--all')
406
+ upstream = args.first
407
+
408
+ upstream ||= %w[origin/master master origin/main main].find { |ref|
409
+ system("git rev-parse --verify #{ref} >/dev/null 2>&1")
410
+ }
411
+
412
+ unless upstream
413
+ puts "Cannot find master or origin/master"
414
+ next
415
+ end
416
+
417
+ forkpoint = `git merge-base --fork-point #{upstream} HEAD 2>/dev/null`.strip
418
+ if forkpoint.empty?
419
+ forkpoint = `git merge-base #{upstream} HEAD 2>/dev/null`.strip
420
+ end
421
+
422
+ if forkpoint.empty?
423
+ puts "Could not find fork point"
424
+ next
425
+ end
426
+
427
+ if show_all
428
+ system('git', 'diff', '--name-only', "#{forkpoint}...HEAD")
429
+ else
430
+ system('git', 'diff', '--name-only', '--relative', "#{forkpoint}...HEAD")
431
+ end
432
+ }
433
+
378
434
  hiiro.add_subcmd(:ancestor) { |*args|
379
435
  case args.length
380
436
  when 0
@@ -401,6 +457,4 @@ hiiro.add_subcmd(:ancestor) { |*args|
401
457
  end
402
458
  }
403
459
 
404
- hiiro.add_default { manager.help }
405
-
406
460
  hiiro.run
data/bin/h-buffer CHANGED
@@ -27,8 +27,7 @@ def select_buffer(partial = nil)
27
27
  return nil if names.empty?
28
28
  return names.first if names.length == 1
29
29
 
30
- require 'open3'
31
- selected, status = Open3.capture2('sk', '--no-sort', stdin_data: names.join("\n"))
30
+ selected, status = Hiiro::Fuzzyfind.select(names)
32
31
  return nil unless status.success?
33
32
 
34
33
  selected.strip.empty? ? nil : selected.strip
@@ -112,7 +111,7 @@ o.add_subcmd(:select) do |*args|
112
111
  h[line] = buffer_name
113
112
  end
114
113
 
115
- selected = Hiiro::Sk.map_select(lines)
114
+ selected = o.fuzzyfind_from_map(lines)
116
115
 
117
116
  if selected
118
117
  print selected
data/bin/h-link CHANGED
@@ -275,8 +275,7 @@ o.add_subcmd(:select) do |*args|
275
275
  lines = lm.hash_matches?(lines, *args)
276
276
  end
277
277
 
278
- require 'open3'
279
- selected, status = Open3.capture2('sk', stdin_data: lines.keys.join("\n"))
278
+ selected, status = o.fuzzyfind(lines.keys)
280
279
 
281
280
  if status.success? && !selected.strip.empty?
282
281
  link = lines[selected.strip]
@@ -349,8 +348,7 @@ o.add_subcmd(:open) do |*args|
349
348
  lines = lm.hash_matches?(lines, *args)
350
349
  end
351
350
 
352
- require 'open3'
353
- selected, status = Open3.capture2('sk', stdin_data: lines.keys.join("\n"))
351
+ selected, status = o.fuzzyfind(lines.keys)
354
352
 
355
353
  if status.success? && !selected.strip.empty?
356
354
  link = lines[selected.strip]
data/bin/h-pane CHANGED
@@ -60,17 +60,6 @@ o.add_subcmd(:resize) { |*args|
60
60
  system('tmux', 'resize-pane', *args)
61
61
  }
62
62
 
63
- o.add_subcmd(:history) { |pane_id=nil|
64
- entries = Hiiro::History.by_pane(pane_id)
65
- if entries.empty?
66
- puts "No history for this pane"
67
- else
68
- puts "History for pane: #{pane_id || ENV['TMUX_PANE'] || 'current'}"
69
- puts
70
- entries.last(20).each_with_index { |e, i| puts e.oneline(i + 1) }
71
- end
72
- }
73
-
74
63
  o.add_subcmd(:select) do |*args|
75
64
  # Get all panes with details
76
65
  output = `tmux list-panes -a -F '\#{session_name}:\#{window_index}.\#{pane_index} [\#{pane_current_command}] \#{pane_current_path}'`.strip
@@ -85,7 +74,7 @@ o.add_subcmd(:select) do |*args|
85
74
  h[line] = pane_id
86
75
  end
87
76
 
88
- selected = Hiiro::Sk.map_select(lines)
77
+ selected = o.fuzzyfind_from_map(lines)
89
78
 
90
79
  if selected
91
80
  print selected
data/bin/h-pr CHANGED
@@ -21,10 +21,6 @@ class PRManager
21
21
  puts
22
22
  puts "Subcommands:"
23
23
  puts " save [PR_NUMBER] Record PR for this task (auto-detects if omitted)"
24
- puts " history List PR history (oldest to newest)"
25
- puts " history --worktree=X Filter by worktree"
26
- puts " history --task=X Filter by task"
27
- puts " history --session=X Filter by tmux session"
28
24
  puts " current Show current branch's PR info"
29
25
  puts " open [PR_NUMBER] Open PR in browser"
30
26
  puts " view [PR_NUMBER] View PR details in terminal"
@@ -67,35 +63,6 @@ class PRManager
67
63
  true
68
64
  end
69
65
 
70
- def history(args = [])
71
- filters = parse_filters(args)
72
- data = load_data
73
- prs = data['prs'] || []
74
-
75
- if prs.empty?
76
- puts "No PRs recorded."
77
- puts "Use 'h pr save' to record the current PR."
78
- return
79
- end
80
-
81
- # Apply filters
82
- prs = filter_entries(prs, filters)
83
-
84
- if prs.empty?
85
- puts "No PRs match the given filters."
86
- return
87
- end
88
-
89
- # Sort by created_at (oldest first)
90
- prs = prs.sort_by { |p| p['created_at'] || '' }
91
-
92
- puts "PR history (oldest to newest):"
93
- puts
94
- prs.each_with_index do |pr, idx|
95
- puts format_entry(pr, idx + 1)
96
- end
97
- end
98
-
99
66
  def current
100
67
  pr_info = fetch_pr_info
101
68
  unless pr_info
@@ -169,36 +136,6 @@ class PRManager
169
136
  }
170
137
  end
171
138
 
172
- def parse_filters(args)
173
- filters = {}
174
- args.each do |arg|
175
- case arg
176
- when /^--worktree=(.+)$/
177
- filters[:worktree] = $1
178
- when /^--task=(.+)$/
179
- filters[:task] = $1
180
- when /^--session=(.+)$/
181
- filters[:session] = $1
182
- when /^-w(.+)$/
183
- filters[:worktree] = $1
184
- when /^-t(.+)$/
185
- filters[:task] = $1
186
- when /^-s(.+)$/
187
- filters[:session] = $1
188
- end
189
- end
190
- filters
191
- end
192
-
193
- def filter_entries(entries, filters)
194
- entries.select do |entry|
195
- next false if filters[:worktree] && !entry['worktree']&.include?(filters[:worktree])
196
- next false if filters[:task] && !entry['task']&.include?(filters[:task])
197
- next false if filters[:session] && entry.dig('tmux', 'session') != filters[:session]
198
- true
199
- end
200
- end
201
-
202
139
  def format_entry(entry, num)
203
140
  lines = []
204
141
  lines << "#{num}. PR ##{entry['number']}: #{entry['title']}"
@@ -541,7 +478,6 @@ hiiro.add_subcmd(:link) { |*args|
541
478
 
542
479
  hiiro.add_subcmd(:edit) { system(ENV['EDITOR'] || 'nvim', __FILE__) }
543
480
  hiiro.add_subcmd(:save) { |pr_number=nil| manager.save(pr_number) }
544
- hiiro.add_subcmd(:history) { |*args| manager.history(args) }
545
481
  hiiro.add_subcmd(:current) { manager.current }
546
482
  hiiro.add_subcmd(:open) { |pr_number=nil| manager.open(pr_number) }
547
483
  hiiro.add_subcmd(:view) { |pr_number=nil| manager.view(pr_number) }
@@ -566,7 +502,7 @@ hiiro.add_subcmd(:select) do |*args|
566
502
  h[display] = pr['number'].to_s
567
503
  end
568
504
 
569
- selected = Hiiro::Sk.map_select(lines)
505
+ selected = hiiro.fuzzyfind_from_map(lines)
570
506
 
571
507
  if selected
572
508
  print selected
@@ -602,7 +538,7 @@ hiiro.add_subcmd(:pin) do |ref = nil, *args|
602
538
  h[display] = pr
603
539
  end
604
540
 
605
- pr_info = Hiiro::Sk.map_select(lines)
541
+ pr_info = hiiro.fuzzyfind_from_map(lines)
606
542
  unless pr_info
607
543
  puts "No PR selected"
608
544
  next
@@ -643,7 +579,7 @@ hiiro.add_subcmd(:unpin) do |ref = nil, *args|
643
579
  h[pinned_manager.display_pinned(pr, idx)] = pr['number'].to_s
644
580
  end
645
581
 
646
- pr_number = Hiiro::Sk.map_select(lines)
582
+ pr_number = hiiro.fuzzyfind_from_map(lines)
647
583
  unless pr_number
648
584
  puts "No PR selected"
649
585
  next
data/bin/h-project CHANGED
@@ -155,7 +155,7 @@ o.add_subcmd(:select) { |*args|
155
155
  h[display] = path
156
156
  end
157
157
 
158
- selected = Hiiro::Sk.map_select(lines)
158
+ selected = o.fuzzyfind_from_map(lines)
159
159
 
160
160
  if selected
161
161
  print selected
data/bin/h-session CHANGED
@@ -60,16 +60,4 @@ o.add_subcmd(:info) { |*args|
60
60
  system('tmux', 'display-message', '-p', '#{session_name}: #{session_windows} windows, #{session_attached} attached', *args)
61
61
  }
62
62
 
63
- o.add_subcmd(:history) { |session_name=nil|
64
- session_name ||= `tmux display-message -p '#S'`.strip if ENV['TMUX']
65
- entries = Hiiro::History.by_session(session_name)
66
- if entries.empty?
67
- puts "No history for this session"
68
- else
69
- puts "History for session: #{session_name || 'current'}"
70
- puts
71
- entries.last(20).each_with_index { |e, i| puts e.oneline(i + 1) }
72
- end
73
- }
74
-
75
63
  o.run
data/bin/h-sha CHANGED
@@ -18,7 +18,7 @@ Hiiro.init(*ARGV, plugins: [Pins]) { |hiiro|
18
18
  h[line] = sha
19
19
  end
20
20
 
21
- selected = Hiiro::Sk.map_select(lines)
21
+ selected = hiiro.fuzzyfind_from_map(lines)
22
22
 
23
23
  if selected
24
24
  print selected
@@ -44,12 +44,7 @@ Hiiro.init(*ARGV, plugins: [Pins]) { |hiiro|
44
44
  next if sha.empty?
45
45
  end
46
46
 
47
- require 'open3'
48
- Open3.popen3('pbcopy') do |stdin, stdout, stderr, wait_thr|
49
- stdin.write(sha)
50
- stdin.close
51
- wait_thr.value
52
- end
47
+ Hiiro::Shell.pipe(sha, 'pbcopy')
53
48
  puts "Copied #{sha} to clipboard"
54
49
  end
55
50
 
data/bin/h-window CHANGED
@@ -56,18 +56,6 @@ o.add_subcmd(:unlink) { |*args|
56
56
  system('tmux', 'unlink-window', *args)
57
57
  }
58
58
 
59
- o.add_subcmd(:history) { |window_id=nil|
60
- window_id ||= `tmux display-message -p '#I'`.strip if ENV['TMUX']
61
- entries = Hiiro::History.by_window(window_id)
62
- if entries.empty?
63
- puts "No history for this window"
64
- else
65
- puts "History for window: #{window_id || 'current'}"
66
- puts
67
- entries.last(20).each_with_index { |e, i| puts e.oneline(i + 1) }
68
- end
69
- }
70
-
71
59
  o.add_subcmd(:select) do |*args|
72
60
  # Get all windows with details
73
61
  output = `tmux list-windows -a -F '\#{session_name}:\#{window_index} \#{window_name} [\#{window_panes} panes]'`.strip
@@ -82,7 +70,7 @@ o.add_subcmd(:select) do |*args|
82
70
  h[line] = window_id
83
71
  end
84
72
 
85
- selected = Hiiro::Sk.map_select(lines)
73
+ selected = o.fuzzyfind_from_map(lines)
86
74
 
87
75
  if selected
88
76
  print selected
data/bin/h-wtree CHANGED
@@ -28,7 +28,7 @@ Hiiro.run(*ARGV) do |h|
28
28
  hash[line] = path
29
29
  end
30
30
 
31
- selected = Hiiro::Sk.map_select(lines)
31
+ selected = h.fuzzyfind_from_map(lines)
32
32
 
33
33
  if selected
34
34
  print selected
@@ -0,0 +1,32 @@
1
+ require_relative 'shell'
2
+
3
+ class Hiiro
4
+ class Fuzzyfind
5
+ TOOLS = %w[sk fzf]
6
+
7
+ def self.tool
8
+ TOOLS.find { |name| system("command -v #{name} 2>/dev/null") }
9
+ end
10
+
11
+ def self.tool!
12
+ match = tool
13
+
14
+ return match if match
15
+
16
+ puts "ERROR: No fuzzyfinder found!"
17
+ exit 1
18
+ end
19
+
20
+ def self.select(lines)
21
+ Shell.pipe_lines(lines, tool!)
22
+ end
23
+
24
+ def self.map_select(mapping)
25
+ keys = mapping.keys
26
+
27
+ key = select(keys)
28
+
29
+ mapping[key.to_s.chomp]
30
+ end
31
+ end
32
+ end
data/lib/hiiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.86"
2
+ VERSION = "0.1.87"
3
3
  end