hiiro 0.1.99 → 0.1.100

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: b479873293dbb050b59b4b48fb44c0c8025ab9eacd30b18c23ac1603adc02b57
4
- data.tar.gz: 24a2e55806f6005e77b404f673ea734c95079769f7bbb67dce11b6979a45a6da
3
+ metadata.gz: 7cdf6efd70c63c229c4b725326a98734a8c8f90d8bdcc161e5ab9c8ae24a126e
4
+ data.tar.gz: fb154e9c6a38f502c832723db590a015219427a4634438510883664d92a12c1c
5
5
  SHA512:
6
- metadata.gz: d56e0b230283bd5f20dfc9954d81522ae54978aef4d34e338565dd1d85bf7d6ac45b16fce11973fdbeb3647687a0dba5be014c2a147274e2b29635ff25648934
7
- data.tar.gz: a45fb54fdd7de933aadd8bbae81afe8769f077c83cc7c14c625206177a957034973ee4f6bc75f418467c9239f63bc2ebcd5676dda668c2bf40a27b4ffcc4cb30
6
+ metadata.gz: 1a54a7a70422bc807f870eb22db43df60d203b8459e41009e0e70842abb07a07cf1c467850dc3202cab5056ecee56d942a84f58c6d34a79caef49a94436e5db7
7
+ data.tar.gz: a04e962764a5f1d336de73e49a9c0f059bcdbb120aa11e2e7509e2029ab11abad5577ef152984e99cd3e705fd20ba83f71e1141aa1b741cf8b02cdbafa54161d
data/bin/h-branch CHANGED
@@ -143,6 +143,27 @@ Hiiro.run(*ARGV, plugins: [Tasks]) do
143
143
  end
144
144
  end
145
145
 
146
+ add_subcmd(:copy) do |*copy_args|
147
+ branches = git.branches(sort_by: 'authordate', ignore_case: true)
148
+
149
+ lines = branches.each_with_object({}) do |name, h|
150
+ h[" #{name}"] = name
151
+ end
152
+
153
+ if copy_args.any?
154
+ lines = hash_matches?(lines, *copy_args)
155
+ end
156
+
157
+ require 'open3'
158
+ selected, status = Open3.capture2('sk', '--no-sort', '--tac', stdin_data: lines.keys.join("\n"))
159
+
160
+ if status.success? && !selected.strip.empty?
161
+ branch = lines[selected.chomp]
162
+ Hiiro::Shell.pipe(branch, 'pbcopy')
163
+ puts "Copied branch '#{branch}' to clipboard"
164
+ end
165
+ end
166
+
146
167
  add_subcmd(:co, :checkout) { |branch = nil, *checkout_args|
147
168
  unless branch
148
169
  # Use sk to select a branch
data/bin/h-link CHANGED
@@ -275,9 +275,9 @@ Hiiro.run(*ARGV, plugins: [Tmux, Pins], links_file: lm.links_file) do
275
275
  lines = lm.hash_matches?(lines, *select_args)
276
276
  end
277
277
 
278
- selected, status = fuzzyfind(lines.keys)
278
+ selected = fuzzyfind(lines.keys)
279
279
 
280
- if status.success? && !selected.strip.empty?
280
+ if !selected.strip.empty?
281
281
  link = lines[selected.strip]
282
282
  if link
283
283
  url = link.url
@@ -292,6 +292,38 @@ Hiiro.run(*ARGV, plugins: [Tmux, Pins], links_file: lm.links_file) do
292
292
  end
293
293
  end
294
294
 
295
+ add_subcmd(:copy) do |*copy_args|
296
+ links = lm.load_links
297
+
298
+ if links.empty?
299
+ STDERR.puts "No links saved."
300
+ next
301
+ end
302
+
303
+ lines = lm.load_link_hash(links)
304
+
305
+ if copy_args.any?
306
+ lines = lm.hash_matches?(lines, *copy_args)
307
+ end
308
+
309
+ selected = fuzzyfind(lines.keys)
310
+
311
+ if !selected.strip.empty?
312
+ link = lines[selected.strip]
313
+ if link
314
+ url = link.url
315
+
316
+ if lm.has_placeholders?(url)
317
+ values = lm.prompt_for_placeholder_values(url, link)
318
+ url = lm.substitute_placeholders(url, values)
319
+ end
320
+
321
+ Hiiro::Shell.pipe(url, 'pbcopy')
322
+ puts "Copied URL '#{url}' to clipboard"
323
+ end
324
+ end
325
+ end
326
+
295
327
  add_subcmd(:editall) do |*editall_args|
296
328
  links_before = lm.load_links
297
329
  system(ENV['EDITOR'] || 'vim', lm.links_file)
@@ -348,9 +380,9 @@ Hiiro.run(*ARGV, plugins: [Tmux, Pins], links_file: lm.links_file) do
348
380
  lines = lm.hash_matches?(lines, *open_args)
349
381
  end
350
382
 
351
- selected, status = fuzzyfind(lines.keys)
383
+ selected = fuzzyfind(lines.keys)
352
384
 
353
- if status.success? && !selected.strip.empty?
385
+ if !selected.strip.empty?
354
386
  link = lines[selected.strip]
355
387
  if link
356
388
  url = link.url
data/bin/h-pane CHANGED
@@ -84,6 +84,17 @@ Hiiro.run(*ARGV, plugins: [Pins]) do
84
84
  end
85
85
  }
86
86
 
87
+ add_subcmd(:copy) { |target = nil, *args|
88
+ if target.nil?
89
+ target = fuzzyfind_from_map(tmux.panes(all: true).name_map)
90
+ end
91
+
92
+ if target
93
+ Hiiro::Shell.pipe(target, 'pbcopy')
94
+ puts "Copied pane '#{target}' to clipboard"
95
+ end
96
+ }
97
+
87
98
  add_subcmd(:sw, :switch) { |target = nil, *args|
88
99
  if target.nil?
89
100
  target = fuzzyfind_from_map(tmux.panes(all: true).name_map)
data/bin/h-pr CHANGED
@@ -510,6 +510,33 @@ Hiiro.run(*ARGV, plugins: [Tasks, Tmux, Pins]) do
510
510
  end
511
511
  end
512
512
 
513
+ add_subcmd(:copy) do |*args|
514
+ output = `gh pr list --author @me --state open --json number,title,headRefName 2>/dev/null`.strip
515
+
516
+ if output.empty?
517
+ STDERR.puts "No open PRs found"
518
+ next
519
+ end
520
+
521
+ prs = JSON.parse(output) rescue []
522
+ if prs.empty?
523
+ STDERR.puts "No open PRs found"
524
+ next
525
+ end
526
+
527
+ lines = prs.each_with_object({}) do |pr, h|
528
+ display = "##{pr['number']} [#{pr['headRefName']}] #{pr['title']}"
529
+ h[display] = pr['number'].to_s
530
+ end
531
+
532
+ selected = fuzzyfind_from_map(lines)
533
+
534
+ if selected
535
+ Hiiro::Shell.pipe(selected, 'pbcopy')
536
+ puts "Copied PR ##{selected} to clipboard"
537
+ end
538
+ end
539
+
513
540
  # === PR Pinning ===
514
541
 
515
542
  add_subcmd(:pin) do |ref = nil, *pin_args|
data/bin/h-project CHANGED
@@ -156,6 +156,32 @@ Hiiro.run(*ARGV) do
156
156
  end
157
157
  }
158
158
 
159
+ # === COPY PROJECT PATH ===
160
+ add_subcmd(:copy) { |*copy_args|
161
+ dirs = project_dirs
162
+ conf = projects_from_config
163
+
164
+ all_projects = dirs.merge(conf)
165
+
166
+ if all_projects.empty?
167
+ STDERR.puts "No projects found"
168
+ next
169
+ end
170
+
171
+ lines = all_projects.each_with_object({}) do |(name, path), h|
172
+ source = conf.key?(name) ? '[config]' : '[dir]'
173
+ display = format("%-15s %s %s", name, source, path)
174
+ h[display] = path
175
+ end
176
+
177
+ selected = fuzzyfind_from_map(lines)
178
+
179
+ if selected
180
+ Hiiro::Shell.pipe(selected, 'pbcopy')
181
+ puts "Copied project path '#{selected}' to clipboard"
182
+ end
183
+ }
184
+
159
185
  # === HELP ===
160
186
  add_subcmd(:help) { |*help_args|
161
187
  puts <<~HELP
data/bin/h-session CHANGED
@@ -112,4 +112,18 @@ Hiiro.run(*ARGV, plugins: [Pins]) do
112
112
  selected = fuzzyfind_from_map(sessions.name_map)
113
113
  print selected if selected
114
114
  end
115
+
116
+ add_subcmd(:copy) do
117
+ sessions = tmux.sessions
118
+ if sessions.empty?
119
+ STDERR.puts "No sessions found"
120
+ next
121
+ end
122
+
123
+ selected = fuzzyfind_from_map(sessions.name_map)
124
+ if selected
125
+ Hiiro::Shell.pipe(selected, 'pbcopy')
126
+ puts "Copied session '#{selected}' to clipboard"
127
+ end
128
+ end
115
129
  end
data/bin/h-window CHANGED
@@ -63,6 +63,17 @@ Hiiro.run(*ARGV, plugins: [Pins]) do
63
63
  end
64
64
  }
65
65
 
66
+ add_subcmd(:copy) { |target = nil, *args|
67
+ if target.nil?
68
+ target = fuzzyfind_from_map(tmux.windows(all: true).name_map)
69
+ end
70
+
71
+ if target
72
+ Hiiro::Shell.pipe(target, 'pbcopy')
73
+ puts "Copied window '#{target}' to clipboard"
74
+ end
75
+ }
76
+
66
77
  add_subcmd(:sw, :switch) { |target = nil, *args|
67
78
  if target.nil?
68
79
  target = fuzzyfind_from_map(tmux.windows(all: true).name_map)
data/bin/h-wtree CHANGED
@@ -34,4 +34,25 @@ Hiiro.run(*ARGV) do
34
34
  print selected
35
35
  end
36
36
  end
37
+
38
+ add_subcmd(:copy) do |*args|
39
+ output = `git worktree list`.strip
40
+
41
+ if output.empty?
42
+ STDERR.puts "No worktrees found"
43
+ next
44
+ end
45
+
46
+ lines = output.split("\n").each_with_object({}) do |line, hash|
47
+ path = line.split.first
48
+ hash[line] = path
49
+ end
50
+
51
+ selected = fuzzyfind_from_map(lines)
52
+
53
+ if selected
54
+ Hiiro::Shell.pipe(selected, 'pbcopy')
55
+ puts "Copied worktree path '#{selected}' to clipboard"
56
+ end
57
+ end
37
58
  end
data/lib/hiiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.99"
2
+ VERSION = "0.1.100"
3
3
  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.99
4
+ version: 0.1.100
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota