hiiro 0.1.9 → 0.1.10
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/bin/h-project +176 -0
- data/bin/h-session +1 -21
- data/lib/hiiro/version.rb +1 -1
- metadata +4 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 02e725d64b462fad99b912e4c4772f62601362a0bd1f16eb8949cfb6d22c914e
|
|
4
|
+
data.tar.gz: da6b9e03278b930b82cb730e4fc564d7cc6370614475b8fb784632e1ae2b92c9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 16ae1c908d049742e950cc6b7ee7a90c2c80efb44fb289050ea6dc9589d7ae9f955aea1fe68a5eb24daa389bbf1da82c2422628bb2cbbc68ee7a56a3c6326935
|
|
7
|
+
data.tar.gz: 8591e60b64c1d924b3653439193d9f28a9381a45fde675759eccf3f8604fcf0f0a869b54b749834b080bb30a02a393456fea7b353e3d5f13a17e9947caffe1fc
|
data/bin/h-project
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
load '/Users/unixsuperhero/bin/h'
|
|
3
|
+
|
|
4
|
+
o = Hiiro.init(*ARGV)
|
|
5
|
+
|
|
6
|
+
# Helper to start or attach to a tmux session
|
|
7
|
+
def start_tmux_session(session_name)
|
|
8
|
+
session_name = session_name.to_s
|
|
9
|
+
|
|
10
|
+
unless system('tmux', 'has-session', '-t', session_name)
|
|
11
|
+
system('tmux', 'new', '-d', '-A', '-s', session_name)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
if ENV['TMUX']
|
|
15
|
+
system('tmux', 'switchc', '-t', session_name)
|
|
16
|
+
elsif ENV['NVIM']
|
|
17
|
+
puts "Can't attach to tmux inside a vim terminal"
|
|
18
|
+
else
|
|
19
|
+
system('tmux', 'new', '-A', '-s', session_name)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Get project directories from ~/proj/
|
|
24
|
+
def project_dirs
|
|
25
|
+
Dir.glob(File.join(Dir.home, 'proj', '*/')).map { |path|
|
|
26
|
+
[File.basename(path), path]
|
|
27
|
+
}.to_h
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Get projects from config file
|
|
31
|
+
def projects_from_config
|
|
32
|
+
projects_file = File.join(Dir.home, '.config/hiiro', 'projects.yml')
|
|
33
|
+
|
|
34
|
+
return {} unless File.exist?(projects_file)
|
|
35
|
+
|
|
36
|
+
require 'yaml'
|
|
37
|
+
YAML.safe_load_file(projects_file)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# === OPEN PROJECT (default) ===
|
|
41
|
+
|
|
42
|
+
o.add_subcmd(:open) { |project_name|
|
|
43
|
+
re = /#{project_name}/i
|
|
44
|
+
|
|
45
|
+
conf_matches = projects_from_config.select { |k, v| k.match?(re) }
|
|
46
|
+
dir_matches = project_dirs.select { |proj, path| proj.match?(re) }
|
|
47
|
+
|
|
48
|
+
matches = dir_matches.merge(conf_matches)
|
|
49
|
+
if matches.count > 1
|
|
50
|
+
matches = matches.select { |name, path| name == project_name }
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
case matches.count
|
|
54
|
+
when 0
|
|
55
|
+
name = 'proj'
|
|
56
|
+
path = File.join(Dir.home, 'proj')
|
|
57
|
+
|
|
58
|
+
unless Dir.exist?(path)
|
|
59
|
+
puts "Error: #{path.inspect} does not exist"
|
|
60
|
+
exit 1
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
puts "changing dir: #{path}"
|
|
64
|
+
Dir.chdir(path)
|
|
65
|
+
|
|
66
|
+
start_tmux_session(name)
|
|
67
|
+
when 1
|
|
68
|
+
name, path = matches.first
|
|
69
|
+
|
|
70
|
+
puts "changing dir: #{path}"
|
|
71
|
+
Dir.chdir(path)
|
|
72
|
+
|
|
73
|
+
start_tmux_session(name)
|
|
74
|
+
when (2..)
|
|
75
|
+
puts "ERROR: Multiple matches found"
|
|
76
|
+
puts
|
|
77
|
+
puts "Matches:"
|
|
78
|
+
matches.each { |name, path|
|
|
79
|
+
puts format(" %s: %s", name, path)
|
|
80
|
+
}
|
|
81
|
+
end
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
# === LIST PROJECTS ===
|
|
85
|
+
|
|
86
|
+
o.add_subcmd(:list) { |*args|
|
|
87
|
+
dirs = project_dirs
|
|
88
|
+
conf = projects_from_config
|
|
89
|
+
|
|
90
|
+
all_projects = dirs.merge(conf)
|
|
91
|
+
|
|
92
|
+
puts "Projects:"
|
|
93
|
+
puts
|
|
94
|
+
all_projects.keys.sort.each do |name|
|
|
95
|
+
path = all_projects[name]
|
|
96
|
+
source = conf.key?(name) ? '[config]' : '[dir]'
|
|
97
|
+
puts format(" %-12s %-8s %s", name, source, path)
|
|
98
|
+
end
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
o.add_subcmd(:ls) { |*args|
|
|
102
|
+
o.run_subcmd(:list, *args)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
# === SHOW CONFIG FILE ===
|
|
106
|
+
|
|
107
|
+
o.add_subcmd(:config) { |*args|
|
|
108
|
+
projects_file = File.join(Dir.home, '.config/hiiro', 'projects.yml')
|
|
109
|
+
|
|
110
|
+
if File.exist?(projects_file)
|
|
111
|
+
puts File.read(projects_file)
|
|
112
|
+
else
|
|
113
|
+
puts "No config file found at: #{projects_file}"
|
|
114
|
+
puts
|
|
115
|
+
puts "Create it with YAML format:"
|
|
116
|
+
puts " project_name: /path/to/project"
|
|
117
|
+
end
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
# === EDIT CONFIG FILE ===
|
|
121
|
+
|
|
122
|
+
o.add_subcmd(:edit) { |*args|
|
|
123
|
+
projects_file = File.join(Dir.home, '.config/hiiro', 'projects.yml')
|
|
124
|
+
editor = ENV['EDITOR'] || 'vim'
|
|
125
|
+
|
|
126
|
+
# Create config dir if needed
|
|
127
|
+
config_dir = File.dirname(projects_file)
|
|
128
|
+
Dir.mkdir(config_dir) unless Dir.exist?(config_dir)
|
|
129
|
+
|
|
130
|
+
# Create empty file if it doesn't exist
|
|
131
|
+
unless File.exist?(projects_file)
|
|
132
|
+
File.write(projects_file, "# Project aliases\n# project_name: /path/to/project\n")
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
exec(editor, projects_file)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
# === HELP ===
|
|
139
|
+
|
|
140
|
+
o.add_subcmd(:help) { |*args|
|
|
141
|
+
puts <<~HELP
|
|
142
|
+
h-project - Project directory and tmux session manager
|
|
143
|
+
|
|
144
|
+
USAGE:
|
|
145
|
+
h-project <project_name> Open project (fuzzy match) and start tmux session
|
|
146
|
+
h-project open <project_name> Same as above
|
|
147
|
+
h-project list List all known projects
|
|
148
|
+
h-project ls Alias for list
|
|
149
|
+
h-project config Show config file contents
|
|
150
|
+
h-project edit Edit config file
|
|
151
|
+
|
|
152
|
+
SOURCES:
|
|
153
|
+
Projects are discovered from two sources:
|
|
154
|
+
1. Directories in ~/proj/
|
|
155
|
+
2. Entries in ~/.config/hiiro/projects.yml
|
|
156
|
+
|
|
157
|
+
CONFIG FORMAT (projects.yml):
|
|
158
|
+
project_name: /path/to/project
|
|
159
|
+
another: /some/other/path
|
|
160
|
+
|
|
161
|
+
MATCHING:
|
|
162
|
+
Project names are matched using regex (case insensitive).
|
|
163
|
+
If multiple matches are found, an exact match is preferred.
|
|
164
|
+
If still ambiguous, all matches are displayed.
|
|
165
|
+
HELP
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
# === DEFAULT SUBCOMMAND ===
|
|
169
|
+
|
|
170
|
+
o.default_subcommand(:open)
|
|
171
|
+
|
|
172
|
+
if o.runnable?
|
|
173
|
+
o.run
|
|
174
|
+
else
|
|
175
|
+
o.run_subcmd(:help)
|
|
176
|
+
end
|
data/bin/h-session
CHANGED
|
@@ -1,26 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
require 'pry'
|
|
5
|
-
require 'rspec'
|
|
6
|
-
|
|
7
|
-
# $> h session
|
|
8
|
-
#
|
|
9
|
-
# Subcommand required!
|
|
10
|
-
#
|
|
11
|
-
# Possible subcommands:
|
|
12
|
-
# pin (subcommand) /Users/unixsuperhero/.config/hiiro/plugins/pins.rb:12
|
|
13
|
-
# edit (subcommand) /Users/unixsuperhero/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/hiiro-0.1.8/lib/hiiro.rb:14
|
|
14
|
-
# ses (subcommand) /Users/unixsuperhero/bin/h-session:99
|
|
15
|
-
# ls (subcommand) /Users/unixsuperhero/bin/h-session:111
|
|
16
|
-
# new (subcommand) /Users/unixsuperhero/bin/h-session:115
|
|
17
|
-
# kill (subcommand) /Users/unixsuperhero/bin/h-session:119
|
|
18
|
-
# attach (subcommand) /Users/unixsuperhero/bin/h-session:123
|
|
19
|
-
# rename (subcommand) /Users/unixsuperhero/bin/h-session:127
|
|
20
|
-
# switch (subcommand) /Users/unixsuperhero/bin/h-session:131
|
|
21
|
-
# detach (subcommand) /Users/unixsuperhero/bin/h-session:135
|
|
22
|
-
# has (subcommand) /Users/unixsuperhero/bin/h-session:139
|
|
23
|
-
# info (subcommand) /Users/unixsuperhero/bin/h-session:143
|
|
3
|
+
load File.join(Dir.home, 'bin', 'h')
|
|
24
4
|
|
|
25
5
|
o = Hiiro.init(*ARGV, plugins: [Pins])
|
|
26
6
|
|
data/lib/hiiro/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
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.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joshua Toyota
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: pry
|
|
@@ -42,6 +41,7 @@ files:
|
|
|
42
41
|
- bin/h-buffer
|
|
43
42
|
- bin/h-pane
|
|
44
43
|
- bin/h-plugin
|
|
44
|
+
- bin/h-project
|
|
45
45
|
- bin/h-session
|
|
46
46
|
- bin/h-task
|
|
47
47
|
- bin/h-video
|
|
@@ -72,7 +72,6 @@ metadata:
|
|
|
72
72
|
homepage_uri: https://github.com/unixsuperhero/hiiro
|
|
73
73
|
source_code_uri: https://github.com/unixsuperhero/hiiro
|
|
74
74
|
changelog_uri: https://github.com/unixsuperhero/hiiro/blob/main/CHANGELOG.md
|
|
75
|
-
post_install_message:
|
|
76
75
|
rdoc_options: []
|
|
77
76
|
require_paths:
|
|
78
77
|
- lib
|
|
@@ -87,8 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
87
86
|
- !ruby/object:Gem::Version
|
|
88
87
|
version: '0'
|
|
89
88
|
requirements: []
|
|
90
|
-
rubygems_version: 3.
|
|
91
|
-
signing_key:
|
|
89
|
+
rubygems_version: 3.6.9
|
|
92
90
|
specification_version: 4
|
|
93
91
|
summary: A lightweight CLI framework for Ruby
|
|
94
92
|
test_files: []
|