hiiro 0.1.205 → 0.1.207
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/queue.rb +9 -6
- data/lib/hiiro/tasks.rb +3 -40
- data/lib/hiiro/tmux/session.rb +29 -7
- data/lib/hiiro/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 052c2d9a3c7a88df4edd8a75173aabe9148b6102774402aaa7b07597afe91326
|
|
4
|
+
data.tar.gz: 32afdbc0de57463c5a0714558f2abca31b96ff43873623baac008b8681d21db2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 69f92f2bc0fd2ec8931121c528b8aa81a5336124e81071f79075760fb7afe37216c8c270f0ccaed771b3caf2e048ec2628c09110be2497ea7d7ece1bdb3ce60d
|
|
7
|
+
data.tar.gz: 0634315a52af0fa1de48d66af87d068d003d4eedddffc083fcac9a8df9fb9c58d4d7a51d6a1787d19821990b69dce8bafef6edb8859fda1215cc7cbd4d2ce773
|
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
|
|
@@ -508,9 +509,16 @@ class Hiiro
|
|
|
508
509
|
opts = Hiiro::Options.parse(args) do
|
|
509
510
|
option(:task, short: :t, desc: 'Task name')
|
|
510
511
|
flag(:choose, short: :T, desc: 'Choose task interactively')
|
|
512
|
+
flag(:session, short: :s, desc: 'Use current tmux session')
|
|
511
513
|
end
|
|
512
514
|
args = opts.args
|
|
513
515
|
ti = q.resolve_task_info(opts, h, task_info)
|
|
516
|
+
|
|
517
|
+
if opts.session
|
|
518
|
+
session_name = h.tmux_client.current_session&.name
|
|
519
|
+
ti = (ti || {}).merge(session_name: session_name) if session_name
|
|
520
|
+
end
|
|
521
|
+
|
|
514
522
|
name = args.first
|
|
515
523
|
|
|
516
524
|
if name.nil?
|
|
@@ -661,12 +669,7 @@ class Hiiro
|
|
|
661
669
|
end
|
|
662
670
|
|
|
663
671
|
def tree_name
|
|
664
|
-
doc.front_matter['tree_name']
|
|
665
|
-
puts tree_name: tname
|
|
666
|
-
puts task_tree: task&.tree
|
|
667
|
-
puts task_tree_name: task&.tree_name
|
|
668
|
-
puts task_tree_path: task&.tree&.path
|
|
669
|
-
end
|
|
672
|
+
doc.front_matter['tree_name']
|
|
670
673
|
end
|
|
671
674
|
|
|
672
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