hiiro 0.1.204 → 0.1.206

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: 5dbd4e31ff3df97138538c11a18bba336f839479ec862f21cd6f3fba42053373
4
- data.tar.gz: 03ac722ea8387a2a1c35ecefd38bf64b963e51f1e3b8403cfc69647e6c550727
3
+ metadata.gz: 43afc62e3bf52a55f7f155090abc9c326e5ce273f3c90cb6db629ff65535f8cd
4
+ data.tar.gz: cde95c8c0eb5cff21939427af608d1cdfd9f9bd67b0c02d9ac3841e5a0c6768d
5
5
  SHA512:
6
- metadata.gz: 81e354d4de2540dc21fa51b1fb294e8838b8b48005f2de3a93178f6b29db406a8ed2109043dbdd9a363d984e2607c2fa715496499b2a3dcd441207994ccf675f
7
- data.tar.gz: 0a737674dda65146b987937f82ca9211d0f5349735496e4702a5273706e29c3490ed29f595106aac789bbe3faeda4e1720b3a8e1f01d251c96e8a80a71c26b3b
6
+ metadata.gz: 0651e3b77c8601162b5f7d29866f095db404c16380d28f397c3a3c088238b77814eadd002d7ef48615531535c89c53370f509b8c749119eac435128adb860fe7
7
+ data.tar.gz: b30056a4f4b75bc89decbc98ff5a117664aa0d6026251399a8035c92acc3c1f712dcd440d062586418fa38d0085c1c821f63f4861218110cff443b07d74b5e4f
data/bin/h-app CHANGED
@@ -45,8 +45,7 @@ end
45
45
 
46
46
  Hiiro.run(*ARGV) {
47
47
  add_subcmd(:config) {
48
- editor = ENV['EDITOR'] || 'nvim'
49
- system(editor, APPS_FILE)
48
+ edit_files(APPS_FILE)
50
49
  }
51
50
 
52
51
  add_subcmd(:cd) { |app_name=nil|
data/bin/h-branch CHANGED
@@ -119,7 +119,7 @@ end
119
119
  Hiiro.run(*ARGV) do
120
120
  manager = BranchManager.new(self)
121
121
 
122
- add_subcmd(:edit) { system(ENV['EDITOR'] || 'nvim', __FILE__) }
122
+ add_subcmd(:edit) { edit_files(__FILE__) }
123
123
  add_subcmd(:save) { manager.save }
124
124
  add_subcmd(:current) { print `git branch --show-current` }
125
125
  add_subcmd(:info) { manager.current }
data/bin/h-claude CHANGED
@@ -66,8 +66,7 @@ Hiiro.run(*ARGV, plugins: [Pins]) {
66
66
  else
67
67
  tmpfile = Tempfile.new(['claude-inline-', '.md'])
68
68
  tmpfile.close
69
- editor = ENV['EDITOR'] || 'vim'
70
- system(editor, tmpfile.path)
69
+ edit_files(tmpfile.path)
71
70
  prompt = File.read(tmpfile.path).strip
72
71
  tmpfile.unlink
73
72
  if prompt.empty?
@@ -80,7 +79,6 @@ Hiiro.run(*ARGV, plugins: [Pins]) {
80
79
  }
81
80
 
82
81
  add_subcmd(:loop) { |*args|
83
- editor = ENV['EDITOR'] || 'vim'
84
82
  separator = "-" * 72
85
83
  history = []
86
84
 
@@ -104,7 +102,7 @@ Hiiro.run(*ARGV, plugins: [Pins]) {
104
102
  end
105
103
 
106
104
  tmpfile.close
107
- system(editor, tmpfile.path)
105
+ edit_files(tmpfile.path)
108
106
  content = File.read(tmpfile.path).strip
109
107
  tmpfile.unlink
110
108
 
data/bin/h-commit CHANGED
@@ -3,7 +3,7 @@
3
3
  require "hiiro"
4
4
 
5
5
  Hiiro.run(*ARGV, plugins: [Pins]) do
6
- add_subcmd(:edit) { system(ENV['EDITOR'] || 'nvim', __FILE__) }
6
+ add_subcmd(:edit) { edit_files(__FILE__) }
7
7
 
8
8
  add_subcmd(:select, :sk) { |*select_args|
9
9
  # Pass all args to git log, with sensible defaults
data/bin/h-config CHANGED
@@ -2,50 +2,48 @@
2
2
 
3
3
  require 'hiiro'
4
4
 
5
- def open_config(dir:, file:)
6
- editor = ENV['EDITOR'] || 'nvim'
7
- full_path = File.expand_path(File.join(dir, file))
8
- Dir.chdir(File.expand_path(dir))
9
- system(editor, full_path)
10
- end
11
-
12
5
  Hiiro.run(*ARGV) {
6
+ open_config = ->(dir:, file:) {
7
+ full_path = File.expand_path(File.join(dir, file))
8
+ Dir.chdir(File.expand_path(dir))
9
+ edit_files(full_path)
10
+ }
13
11
  add_subcmd(:vim) {
14
12
  dir = '~/.config/nvim'
15
13
  file = File.exist?(File.expand_path('~/.config/nvim/init.lua')) ? 'init.lua' : 'init.vim'
16
- open_config(dir: dir, file: file)
14
+ open_config.(dir: dir, file: file)
17
15
  }
18
16
 
19
17
  add_subcmd(:git) {
20
18
  make_child(subcmd, *args) {
21
19
  add_subcmd(:global) {
22
- open_config(dir: '~', file: '.gitconfig')
20
+ open_config.(dir: '~', file: '.gitconfig')
23
21
  }
24
22
 
25
23
  add_subcmd(:local) {
26
24
  root = `git rev-parse --show-toplevel`.chomp
27
- open_config(dir: root, file: '.git/config')
25
+ open_config.(dir: root, file: '.git/config')
28
26
  }
29
27
  }.run
30
28
  }
31
29
 
32
30
  add_subcmd(:tmux) {
33
- open_config(dir: '~', file: '.tmux.conf')
31
+ open_config.(dir: '~', file: '.tmux.conf')
34
32
  }
35
33
 
36
34
  add_subcmd(:zsh) {
37
- open_config(dir: '~', file: '.zshrc')
35
+ open_config.(dir: '~', file: '.zshrc')
38
36
  }
39
37
 
40
38
  add_subcmd(:profile) {
41
- open_config(dir: '~', file: '.zprofile')
39
+ open_config.(dir: '~', file: '.zprofile')
42
40
  }
43
41
 
44
42
  add_subcmd(:starship) {
45
- open_config(dir: '~/.config/starship', file: 'starship.toml')
43
+ open_config.(dir: '~/.config/starship', file: 'starship.toml')
46
44
  }
47
45
 
48
46
  add_subcmd(:claude) {
49
- open_config(dir: '~/.claude', file: 'settings.json')
47
+ open_config.(dir: '~/.claude', file: 'settings.json')
50
48
  }
51
49
  }
data/bin/h-link CHANGED
@@ -332,7 +332,7 @@ Hiiro.run(*ARGV, plugins: [Pins], links_file: lm.links_file) do
332
332
 
333
333
  add_subcmd(:editall) do |*editall_args|
334
334
  links_before = lm.load_links
335
- system(ENV['EDITOR'] || 'vim', lm.links_file)
335
+ edit_files(lm.links_file)
336
336
 
337
337
  begin
338
338
  links_after = lm.load_links
data/bin/h-plugin CHANGED
@@ -21,7 +21,7 @@ Hiiro.run(*ARGV, plugins: [Pins], dir: BASE_DIR) do
21
21
 
22
22
  add_subcmd(:edit) { |*edit_args|
23
23
  if edit_args.none?
24
- system(ENV['EDITOR'] || 'safe_nvim', __FILE__)
24
+ edit_files(__FILE__)
25
25
  else
26
26
  pm = Hiiro::Matcher.new(plugin_files) { |f| File.basename(f) }
27
27
  plugins = edit_args.flat_map { |arg| pm.by_prefix(arg).matches.map(&:item) }.uniq
@@ -29,7 +29,7 @@ Hiiro.run(*ARGV, plugins: [Pins], dir: BASE_DIR) do
29
29
  if plugins.none?
30
30
  puts "No matching plugins found for: #{edit_args.map(&:inspect).join(' ')}"
31
31
  else
32
- system(ENV['EDITOR'] || 'safe_nvim', *plugins)
32
+ edit_files(*plugins)
33
33
  end
34
34
  end
35
35
  }
data/bin/h-pr CHANGED
@@ -723,7 +723,7 @@ Hiiro.run(*ARGV, plugins: [Pins]) do
723
723
  end
724
724
  }
725
725
 
726
- add_subcmd(:edit) { system(ENV['EDITOR'] || 'nvim', __FILE__) }
726
+ add_subcmd(:edit) { edit_files(__FILE__) }
727
727
  add_subcmd(:save) { |pr_number=nil| manager.save(pr_number) }
728
728
  add_subcmd(:current) { manager.current }
729
729
  add_subcmd(:open) { |pr_number=nil|
@@ -1132,7 +1132,7 @@ Hiiro.run(*ARGV, plugins: [Pins]) do
1132
1132
  tmpfile.write(lines.join("\n"))
1133
1133
  tmpfile.close
1134
1134
 
1135
- system(ENV['EDITOR'] || 'nvim', tmpfile.path)
1135
+ edit_files(tmpfile.path)
1136
1136
 
1137
1137
  to_add = YAML.safe_load_file(tmpfile.path) || []
1138
1138
  tmpfile.unlink
data/bin/h-project CHANGED
@@ -117,8 +117,6 @@ Hiiro.run(*ARGV) do
117
117
  # === EDIT CONFIG FILE ===
118
118
  add_subcmd(:edit) { |*edit_args|
119
119
  projects_file = File.join(Dir.home, '.config/hiiro', 'projects.yml')
120
- editor = ENV['EDITOR'] || 'vim'
121
-
122
120
  # Create config dir if needed
123
121
  config_dir = File.dirname(projects_file)
124
122
  Dir.mkdir(config_dir) unless Dir.exist?(config_dir)
@@ -128,7 +126,7 @@ Hiiro.run(*ARGV) do
128
126
  File.write(projects_file, "# Project aliases\n# project_name: /path/to/project\n")
129
127
  end
130
128
 
131
- exec(editor, projects_file)
129
+ edit_files(projects_file)
132
130
  }
133
131
 
134
132
  # === SELECT PROJECT ===
data/bin/h-session CHANGED
@@ -157,7 +157,7 @@ Hiiro.run(*ARGV, tasks: true, plugins: [Pins]) do
157
157
  tmpfile.write(orphan_names.to_yaml)
158
158
  tmpfile.close
159
159
 
160
- system(ENV['EDITOR'] || 'nvim', tmpfile.path)
160
+ edit_files(tmpfile.path)
161
161
 
162
162
  to_kill = YAML.safe_load_file(tmpfile.path) || []
163
163
  tmpfile.unlink
data/bin/h-todo CHANGED
@@ -227,8 +227,7 @@ Hiiro.run(*ARGV, todo_file: tm.todo_file) do
227
227
  end
228
228
 
229
229
  add_subcmd(:editall) do |*args|
230
- editor = ENV['EDITOR'] || 'safe_nvim' || 'nvim'
231
- system(editor, tm.todo_file)
230
+ edit_files(tm.todo_file)
232
231
  end
233
232
 
234
233
  add_subcmd(:help) do |*args|
@@ -123,12 +123,7 @@ class Hiiro
123
123
  end
124
124
  end
125
125
 
126
- editor = ENV['EDITOR'] || 'nvim'
127
- if editor.match?(/vim/i)
128
- system(editor, '-O', *resolved)
129
- else
130
- system(editor, *resolved)
131
- end
126
+ h.edit_files(*resolved)
132
127
  end
133
128
  end
134
129
  end
data/lib/hiiro/queue.rb CHANGED
@@ -447,6 +447,7 @@ class Hiiro
447
447
  opts = Hiiro::Options.parse(args) do
448
448
  option(:task, short: :t, desc: 'Task name')
449
449
  flag(:choose, short: :T, desc: 'Choose task interactively')
450
+ flag(:session, short: :s, desc: 'Use current tmux session')
450
451
  end
451
452
 
452
453
  if opts.help?
@@ -457,6 +458,11 @@ class Hiiro
457
458
  args = opts.args
458
459
  ti = q.resolve_task_info(opts, h, task_info)
459
460
 
461
+ if opts.session
462
+ session_name = h.tmux_client.current_session&.name
463
+ ti = (ti || {}).merge(session_name: session_name) if session_name
464
+ end
465
+
460
466
  tmpfile = Tempfile.new(['hq-', '.md'])
461
467
  prompt_file = tmpfile.path
462
468
  if args.empty? && !$stdin.tty?
@@ -476,10 +482,11 @@ class Hiiro
476
482
  end
477
483
 
478
484
  tmpfile.close
479
- editor = ENV['EDITOR'] || 'vim'
480
- editor_args = [editor]
481
- editor_args << '+$' if editor.include?('vim')
482
- system(*editor_args, tmpfile.path)
485
+ if h.vim?
486
+ system(h.editor, '+$', tmpfile.path)
487
+ else
488
+ system(h.editor, tmpfile.path)
489
+ end
483
490
  content = File.read(tmpfile.path).strip
484
491
  tmpfile.unlink
485
492
  if content.empty?
@@ -498,13 +505,19 @@ class Hiiro
498
505
 
499
506
  h.add_subcmd(:wip) { |*args|
500
507
  q.queue_dirs
501
- editor = ENV['EDITOR'] || 'vim'
502
508
  opts = Hiiro::Options.parse(args) do
503
509
  option(:task, short: :t, desc: 'Task name')
504
510
  flag(:choose, short: :T, desc: 'Choose task interactively')
511
+ flag(:session, short: :s, desc: 'Use current tmux session')
505
512
  end
506
513
  args = opts.args
507
514
  ti = q.resolve_task_info(opts, h, task_info)
515
+
516
+ if opts.session
517
+ session_name = h.tmux_client.current_session&.name
518
+ ti = (ti || {}).merge(session_name: session_name) if session_name
519
+ end
520
+
508
521
  name = args.first
509
522
 
510
523
  if name.nil?
@@ -534,9 +547,7 @@ class Hiiro
534
547
  end
535
548
  end
536
549
 
537
- editor_args = [editor]
538
- editor_args << '+$' if editor.include?('vim')
539
- system(*editor_args, path)
550
+ h.edit_files(path)
540
551
  }
541
552
 
542
553
  h.add_subcmd(:ready) { |name = nil|
@@ -122,11 +122,6 @@ class Hiiro
122
122
  true
123
123
  end
124
124
 
125
- def edit_config
126
- editor = ENV['EDITOR'] || 'nvim'
127
- system(editor, config_file)
128
- end
129
-
130
125
  def self.build_hiiro(parent_hiiro, rt, git: nil)
131
126
  parent_hiiro.make_child(:run) do |h|
132
127
  h.add_default do |*run_args|
@@ -204,8 +199,7 @@ class Hiiro
204
199
  tmpfile.write(YAML.dump({ 'new_tool' => template }))
205
200
  tmpfile.close
206
201
 
207
- editor = ENV['EDITOR'] || 'nvim'
208
- system(editor, tmpfile.path)
202
+ h.edit_files(tmpfile.path)
209
203
 
210
204
  begin
211
205
  data = YAML.safe_load_file(tmpfile.path, permitted_classes: [Symbol]) || {}
@@ -229,7 +223,7 @@ class Hiiro
229
223
  end
230
224
 
231
225
  h.add_subcmd(:config) do
232
- rt.edit_config
226
+ h.edit_files(rt.config_file)
233
227
  end
234
228
  end
235
229
  end
@@ -489,7 +489,7 @@ class Hiiro
489
489
  end
490
490
 
491
491
  tmux_info = {
492
- session: ENV['TMUX'] ? `tmux display-message -p '#S'`.chomp : nil,
492
+ session: h.tmux_client.current_session&.name,
493
493
  }
494
494
 
495
495
  task_info = {}
@@ -646,8 +646,7 @@ class Hiiro
646
646
  tmpfile.write(YAML.dump({ 'new_service' => template }))
647
647
  tmpfile.close
648
648
 
649
- editor = ENV['EDITOR'] || 'nvim'
650
- system(editor, tmpfile.path)
649
+ h.edit_files(tmpfile.path)
651
650
 
652
651
  begin
653
652
  data = YAML.safe_load_file(tmpfile.path, permitted_classes: [Symbol]) || {}
@@ -680,8 +679,7 @@ class Hiiro
680
679
  end
681
680
 
682
681
  h.add_subcmd(:config) do
683
- editor = ENV['EDITOR'] || 'nvim'
684
- system(editor, sm.config_file)
682
+ h.edit_files(sm.config_file)
685
683
  end
686
684
 
687
685
  h.add_subcmd(:groups) do
@@ -866,8 +864,7 @@ class Hiiro
866
864
  end
867
865
 
868
866
  def current_tmux_session
869
- return nil unless ENV['TMUX']
870
- `tmux display-message -p '#S'`.chomp
867
+ Hiiro::Tmux::Session.current&.name
871
868
  end
872
869
 
873
870
  def create_tmux_window(session, name)
data/lib/hiiro/tasks.rb CHANGED
@@ -722,7 +722,7 @@ class Hiiro
722
722
  end
723
723
 
724
724
  h.add_subcmd(:edit) do
725
- system(ENV['EDITOR'] || 'nvim', __FILE__)
725
+ h.edit_files(__FILE__)
726
726
  end
727
727
 
728
728
  h.add_subcmd(:todo) do |*todo_args|
@@ -880,9 +880,8 @@ class Hiiro
880
880
  attr_reader :name
881
881
 
882
882
  def self.current
883
- return nil unless ENV['TMUX']
884
-
885
- name = `tmux display-message -p '#S'`.chomp
883
+ name = Hiiro::Tmux::Session.current&.name
884
+ return nil unless name
886
885
  new(name)
887
886
  end
888
887
 
data/lib/hiiro/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Hiiro
2
- VERSION = "0.1.204"
2
+ VERSION = "0.1.206"
3
3
  end
data/lib/hiiro.rb CHANGED
@@ -58,7 +58,7 @@ class Hiiro
58
58
  }
59
59
 
60
60
  hiiro.add_subcmd(:edit, **values) { |*args|
61
- system(ENV['EDITOR'] || 'nvim', hiiro.bin)
61
+ hiiro.edit_files(hiiro.bin)
62
62
  }
63
63
 
64
64
  if hiiro.tasks_enabled?
@@ -154,9 +154,17 @@ class Hiiro
154
154
  ENV['EDITOR'] || editors.first
155
155
  end
156
156
 
157
- def edit_files(*files)
157
+ def vim?
158
+ editor.to_s.match?(/vim/i)
159
+ end
160
+
161
+ def edit_files(*files, max_splits: 3)
158
162
  if editor.match?(/vim/i)
159
- system(editor, '-O', *files)
163
+ if files.count > max_splits.to_i
164
+ system(editor, '-O' + max_splits.to_i.to_s, *files)
165
+ else
166
+ system(editor, '-O', *files)
167
+ end
160
168
  else
161
169
  system(editor, *files)
162
170
  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.204
4
+ version: 0.1.206
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Toyota