hiiro 0.1.206 → 0.1.208
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 +4 -4
- data/lib/hiiro/config.rb +33 -0
- data/lib/hiiro/queue.rb +2 -6
- data/lib/hiiro/tasks.rb +3 -40
- data/lib/hiiro/tmux/session.rb +29 -7
- data/lib/hiiro/version.rb +1 -1
- data/lib/hiiro.rb +1 -26
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 481e1331821875953629a6cac3c704b9867047f8d33cbc0d84c21037ec34ddc0
|
|
4
|
+
data.tar.gz: 9bb8ef3c6c1e1614a9c144e3ff299f824e0c3dc9804ca3c24b616dad35877f76
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc6339585ffc0a60610e279b0745dc3a9c74b5bb19df18025c20c92c2e1061aee36b9deac84fb4dba69b718b8eab0f9d036419baed3221d3fa45b4634315ee2d
|
|
7
|
+
data.tar.gz: '09ded021e3375c1a0414d75ca181d8f8310539f536dae6ab844941c4f0418bed522dff163768a10afa6c0e957ddfac55252d6f355f0e2e928a3487a2bf65b547'
|
data/lib/hiiro/config.rb
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class Hiiro
|
|
2
|
+
class Config
|
|
3
|
+
BASE_DIR = File.join(Dir.home, '.config/hiiro')
|
|
4
|
+
|
|
5
|
+
class << self
|
|
6
|
+
def path(relpath='')
|
|
7
|
+
File.join(BASE_DIR, relpath)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def plugin_files
|
|
11
|
+
user_files = Dir.glob(File.join(plugin_dir, '*.rb'))
|
|
12
|
+
user_basenames = user_files.map { |f| File.basename(f) }
|
|
13
|
+
|
|
14
|
+
gem_plugin_dir = File.join(File.expand_path('../..', __FILE__), 'plugins')
|
|
15
|
+
gem_files = Dir.exist?(gem_plugin_dir) ? Dir.glob(File.join(gem_plugin_dir, '*.rb')) : []
|
|
16
|
+
|
|
17
|
+
fallback_files = gem_files.reject { |f| user_basenames.include?(File.basename(f)) }
|
|
18
|
+
|
|
19
|
+
user_files + fallback_files
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def plugin_dir
|
|
23
|
+
config_dir('plugins')
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def config_dir(subdir=nil)
|
|
27
|
+
File.join(Dir.home, '.config/hiiro', *[subdir].compact).tap do |config_path|
|
|
28
|
+
FileUtils.mkdir_p(config_path) unless Dir.exist?(config_path)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
data/lib/hiiro/queue.rb
CHANGED
|
@@ -146,6 +146,7 @@ class Hiiro
|
|
|
146
146
|
working_dir = tree.path if tree
|
|
147
147
|
elsif prompt_obj.session
|
|
148
148
|
target_session = prompt_obj.session.name
|
|
149
|
+
working_dir = prompt_obj.session.path || working_dir
|
|
149
150
|
end
|
|
150
151
|
|
|
151
152
|
if prompt_obj.tree
|
|
@@ -668,12 +669,7 @@ class Hiiro
|
|
|
668
669
|
end
|
|
669
670
|
|
|
670
671
|
def tree_name
|
|
671
|
-
doc.front_matter['tree_name']
|
|
672
|
-
puts tree_name: tname
|
|
673
|
-
puts task_tree: task&.tree
|
|
674
|
-
puts task_tree_name: task&.tree_name
|
|
675
|
-
puts task_tree_path: task&.tree&.path
|
|
676
|
-
end
|
|
672
|
+
doc.front_matter['tree_name']
|
|
677
673
|
end
|
|
678
674
|
|
|
679
675
|
def session_name
|
data/lib/hiiro/tasks.rb
CHANGED
|
@@ -185,7 +185,7 @@ class Hiiro
|
|
|
185
185
|
puts "#{label}:"
|
|
186
186
|
puts
|
|
187
187
|
|
|
188
|
-
client_map =
|
|
188
|
+
client_map = Hiiro::Tmux::Session.client_map
|
|
189
189
|
|
|
190
190
|
# Collect rows as {prefix, name, tree, branch, session} so we can
|
|
191
191
|
# compute max column widths before rendering.
|
|
@@ -876,43 +876,6 @@ class Hiiro
|
|
|
876
876
|
end
|
|
877
877
|
end
|
|
878
878
|
|
|
879
|
-
class TmuxSession
|
|
880
|
-
attr_reader :name
|
|
881
|
-
|
|
882
|
-
def self.current
|
|
883
|
-
name = Hiiro::Tmux::Session.current&.name
|
|
884
|
-
return nil unless name
|
|
885
|
-
new(name)
|
|
886
|
-
end
|
|
887
|
-
|
|
888
|
-
def self.all
|
|
889
|
-
output = `tmux list-sessions -F '#S' 2>/dev/null`
|
|
890
|
-
output.lines(chomp: true).map { |name| new(name) }
|
|
891
|
-
end
|
|
892
|
-
|
|
893
|
-
# Returns { session_name => "ttysXXX" } for sessions with attached clients.
|
|
894
|
-
# The tty identifies which terminal tab (e.g. Ghostty tab) the client is in.
|
|
895
|
-
def self.client_map
|
|
896
|
-
output = `tmux list-clients -F '\#{client_tty}|\#{session_name}' 2>/dev/null`
|
|
897
|
-
output.lines(chomp: true).each_with_object({}) do |line, map|
|
|
898
|
-
tty, session = line.split('|', 2)
|
|
899
|
-
map[session] ||= tty.delete_prefix('/dev/')
|
|
900
|
-
end
|
|
901
|
-
end
|
|
902
|
-
|
|
903
|
-
def initialize(name)
|
|
904
|
-
@name = name
|
|
905
|
-
end
|
|
906
|
-
|
|
907
|
-
def ==(other)
|
|
908
|
-
other.is_a?(TmuxSession) && name == other.name
|
|
909
|
-
end
|
|
910
|
-
|
|
911
|
-
def to_s
|
|
912
|
-
name
|
|
913
|
-
end
|
|
914
|
-
end
|
|
915
|
-
|
|
916
879
|
class Tree
|
|
917
880
|
attr_reader :path, :head, :branch
|
|
918
881
|
|
|
@@ -1060,7 +1023,7 @@ class Hiiro
|
|
|
1060
1023
|
end
|
|
1061
1024
|
|
|
1062
1025
|
def all_sessions
|
|
1063
|
-
@all_sessions ||=
|
|
1026
|
+
@all_sessions ||= Hiiro::Tmux::Session.all
|
|
1064
1027
|
end
|
|
1065
1028
|
|
|
1066
1029
|
def all_trees
|
|
@@ -1099,7 +1062,7 @@ class Hiiro
|
|
|
1099
1062
|
end
|
|
1100
1063
|
|
|
1101
1064
|
def session
|
|
1102
|
-
@session ||=
|
|
1065
|
+
@session ||= Hiiro::Tmux::Session.current
|
|
1103
1066
|
end
|
|
1104
1067
|
|
|
1105
1068
|
def tree
|
data/lib/hiiro/tmux/session.rb
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
class Hiiro
|
|
2
2
|
class Tmux
|
|
3
3
|
class Session
|
|
4
|
-
FORMAT = '#{session_id}|#{session_name}|#{session_windows}|#{session_attached}|#{session_created}|#{session_last_attached}'
|
|
4
|
+
FORMAT = '#{session_id}|#{session_name}|#{session_windows}|#{session_attached}|#{session_created}|#{session_last_attached}|#{session_path}'
|
|
5
5
|
|
|
6
|
-
attr_reader :id, :name, :windows, :created, :last_attached
|
|
6
|
+
attr_reader :id, :name, :windows, :created, :last_attached, :path
|
|
7
7
|
|
|
8
8
|
def self.from_format_line(line)
|
|
9
9
|
return nil if line.nil? || line.strip.empty?
|
|
10
10
|
|
|
11
|
-
parts = line.strip.split('|',
|
|
11
|
+
parts = line.strip.split('|', 7)
|
|
12
12
|
return nil if parts.size < 4
|
|
13
13
|
|
|
14
|
-
id, name, windows, attached, created, last_attached = parts
|
|
14
|
+
id, name, windows, attached, created, last_attached, path = parts
|
|
15
15
|
|
|
16
16
|
new(
|
|
17
17
|
id: id,
|
|
@@ -19,7 +19,8 @@ class Hiiro
|
|
|
19
19
|
windows: windows.to_i,
|
|
20
20
|
attached: attached == '1',
|
|
21
21
|
created: created.to_i,
|
|
22
|
-
last_attached: last_attached.to_i
|
|
22
|
+
last_attached: last_attached.to_i,
|
|
23
|
+
path: path
|
|
23
24
|
)
|
|
24
25
|
end
|
|
25
26
|
|
|
@@ -30,13 +31,33 @@ class Hiiro
|
|
|
30
31
|
from_format_line(output)
|
|
31
32
|
end
|
|
32
33
|
|
|
33
|
-
def
|
|
34
|
+
def self.all
|
|
35
|
+
output = `tmux list-sessions -F '#{FORMAT}' 2>/dev/null`
|
|
36
|
+
return [] if output.nil? || output.empty?
|
|
37
|
+
|
|
38
|
+
output.each_line.map { |line| from_format_line(line) }.compact
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.client_map
|
|
42
|
+
output = `tmux list-clients -F '\#{client_tty}|\#{session_name}' 2>/dev/null`
|
|
43
|
+
output.lines(chomp: true).each_with_object({}) do |line, map|
|
|
44
|
+
tty, session_name = line.split('|', 2)
|
|
45
|
+
map[session_name] ||= tty.delete_prefix('/dev/')
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def initialize(id:, name:, windows: 0, attached: false, created: 0, last_attached: 0, path: nil)
|
|
34
50
|
@id = id
|
|
35
51
|
@name = name
|
|
36
52
|
@windows = windows
|
|
37
53
|
@attached = attached
|
|
38
54
|
@created = created
|
|
39
55
|
@last_attached = last_attached
|
|
56
|
+
@path = path
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def ==(other)
|
|
60
|
+
other.is_a?(Session) && name == other.name
|
|
40
61
|
end
|
|
41
62
|
|
|
42
63
|
def attached?
|
|
@@ -74,7 +95,8 @@ class Hiiro
|
|
|
74
95
|
windows: windows,
|
|
75
96
|
attached: attached?,
|
|
76
97
|
created: created,
|
|
77
|
-
last_attached: last_attached
|
|
98
|
+
last_attached: last_attached,
|
|
99
|
+
path: path
|
|
78
100
|
}.compact
|
|
79
101
|
end
|
|
80
102
|
|
data/lib/hiiro/version.rb
CHANGED
data/lib/hiiro.rb
CHANGED
|
@@ -5,6 +5,7 @@ require "pry"
|
|
|
5
5
|
require "ostruct"
|
|
6
6
|
|
|
7
7
|
require_relative "hiiro/version"
|
|
8
|
+
require_relative "hiiro/config"
|
|
8
9
|
require_relative "hiiro/bins"
|
|
9
10
|
require_relative "hiiro/fuzzyfind"
|
|
10
11
|
require_relative "hiiro/git"
|
|
@@ -405,32 +406,6 @@ class Hiiro
|
|
|
405
406
|
runner&.values&.[](name)
|
|
406
407
|
end
|
|
407
408
|
|
|
408
|
-
class Config
|
|
409
|
-
class << self
|
|
410
|
-
def plugin_files
|
|
411
|
-
user_files = Dir.glob(File.join(plugin_dir, '*.rb'))
|
|
412
|
-
user_basenames = user_files.map { |f| File.basename(f) }
|
|
413
|
-
|
|
414
|
-
gem_plugin_dir = File.join(File.expand_path('../..', __FILE__), 'plugins')
|
|
415
|
-
gem_files = Dir.exist?(gem_plugin_dir) ? Dir.glob(File.join(gem_plugin_dir, '*.rb')) : []
|
|
416
|
-
|
|
417
|
-
fallback_files = gem_files.reject { |f| user_basenames.include?(File.basename(f)) }
|
|
418
|
-
|
|
419
|
-
user_files + fallback_files
|
|
420
|
-
end
|
|
421
|
-
|
|
422
|
-
def plugin_dir
|
|
423
|
-
config_dir('plugins')
|
|
424
|
-
end
|
|
425
|
-
|
|
426
|
-
def config_dir(subdir=nil)
|
|
427
|
-
File.join(Dir.home, '.config/hiiro', *[subdir].compact).tap do |config_path|
|
|
428
|
-
FileUtils.mkdir_p(config_path) unless Dir.exist?(config_path)
|
|
429
|
-
end
|
|
430
|
-
end
|
|
431
|
-
end
|
|
432
|
-
end
|
|
433
|
-
|
|
434
409
|
def default_subcommand
|
|
435
410
|
Runners::Subcommand.new(
|
|
436
411
|
bin_name,
|
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.
|
|
4
|
+
version: 0.1.208
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joshua Toyota
|
|
@@ -136,6 +136,7 @@ files:
|
|
|
136
136
|
- lib/hiiro.rb
|
|
137
137
|
- lib/hiiro/app_files.rb
|
|
138
138
|
- lib/hiiro/bins.rb
|
|
139
|
+
- lib/hiiro/config.rb
|
|
139
140
|
- lib/hiiro/fuzzyfind.rb
|
|
140
141
|
- lib/hiiro/git.rb
|
|
141
142
|
- lib/hiiro/git/branch.rb
|