reline_pac 0.1.0
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 +7 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/lib/reline_pac/config.rb +24 -0
- data/lib/reline_pac/packages/clipboard.rb +31 -0
- data/lib/reline_pac/packages/completion.rb +39 -0
- data/lib/reline_pac/packages/history.rb +54 -0
- data/lib/reline_pac/packages.rb +23 -0
- data/lib/reline_pac/version.rb +5 -0
- data/lib/reline_pac.rb +17 -0
- data/sig/reline_pac.rbs +8 -0
- metadata +76 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 740719889e0748617fb212cf0c770e9730edc51c09a66ed632a92b2d29039375
|
|
4
|
+
data.tar.gz: fa63ea8cdd0dd5b3f18d7c6c69f81f3aee0b84a0dc3f029bd61a80ddbd15308f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: cfeaf51769cfdb4ca751cabcd20268b4efbcbab7f619f808505268a4979a828fa47a38a892ca62aacbd860681cb826821a6e6b81161026c2fdec8672d1ab0712
|
|
7
|
+
data.tar.gz: f503fb65103614f3ed9001ef1a95e4097383af82b4fa608e004a3616ed22813497f151b8af9ce48f433b4785349af1e2ad9ebb3a713a26007b06a3778aa5ed30
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mizuki-y
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RelinePac
|
|
4
|
+
# Config manages Reline keybindings and package installation.
|
|
5
|
+
class Config
|
|
6
|
+
def initialize
|
|
7
|
+
Packages.install_all
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Add a keybinding that invokes the given LineEditor method symbol.
|
|
11
|
+
# @param key [String] a string such as "\C-r"
|
|
12
|
+
# @param method [Symbol] the LineEditor method to invoke
|
|
13
|
+
def add_keybind(key, method)
|
|
14
|
+
key_bytes = key.bytes
|
|
15
|
+
reline_config.add_default_key_binding(key_bytes, method)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def reline_config
|
|
21
|
+
@reline_config ||= Reline.send(:core).config
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RelinePac
|
|
4
|
+
module Packages
|
|
5
|
+
# Clipboard provides macOS pbcopy/pbpaste integration for Reline.
|
|
6
|
+
module Clipboard
|
|
7
|
+
# Methods adds clipboard operations to Reline::LineEditor.
|
|
8
|
+
module Methods
|
|
9
|
+
def pbpaste(_key)
|
|
10
|
+
text = `pbpaste`.chomp
|
|
11
|
+
insert_text(text)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def pbcopy_kill(_key)
|
|
15
|
+
cut_text = line.byteslice(byte_pointer..-1)
|
|
16
|
+
return unless cut_text && !cut_text.empty?
|
|
17
|
+
|
|
18
|
+
::IO.popen('pbcopy', 'w') { |io| io.write cut_text }
|
|
19
|
+
delete_text(byte_pointer..-1)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.install
|
|
24
|
+
return unless defined?(Reline::LineEditor)
|
|
25
|
+
return if Reline::LineEditor < Methods
|
|
26
|
+
|
|
27
|
+
Reline::LineEditor.prepend(Methods)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RelinePac
|
|
4
|
+
module Packages
|
|
5
|
+
# Completion provides context-aware completion navigation.
|
|
6
|
+
module Completion
|
|
7
|
+
# Methods adds completion-aware navigation to Reline::LineEditor.
|
|
8
|
+
module Methods
|
|
9
|
+
def completion_dialog_visible?
|
|
10
|
+
dialog = @dialogs.find { |d| d.name == :autocomplete }
|
|
11
|
+
dialog&.contents
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def completion_next(key)
|
|
15
|
+
if completion_dialog_visible?
|
|
16
|
+
menu_complete(key)
|
|
17
|
+
else
|
|
18
|
+
ed_next_history(key)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def completion_prev(key)
|
|
23
|
+
if completion_dialog_visible?
|
|
24
|
+
menu_complete_backward(key)
|
|
25
|
+
else
|
|
26
|
+
ed_prev_history(key)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.install
|
|
32
|
+
return unless defined?(Reline::LineEditor)
|
|
33
|
+
return if Reline::LineEditor < Methods
|
|
34
|
+
|
|
35
|
+
Reline::LineEditor.prepend(Methods)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RelinePac
|
|
4
|
+
module Packages
|
|
5
|
+
# History provides fzf-powered history search for Reline.
|
|
6
|
+
module History
|
|
7
|
+
# Methods adds fzf history search to Reline::LineEditor.
|
|
8
|
+
module Methods
|
|
9
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
|
10
|
+
def fzf_history(_key)
|
|
11
|
+
all_history = Reline::HISTORY.to_a
|
|
12
|
+
return if all_history.empty?
|
|
13
|
+
|
|
14
|
+
seen = {}
|
|
15
|
+
filtered = all_history.filter_map do |h|
|
|
16
|
+
stripped = h.strip
|
|
17
|
+
next if stripped.empty? || seen[stripped]
|
|
18
|
+
|
|
19
|
+
seen[stripped] = true
|
|
20
|
+
h
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
display = filtered.map { |h| h.gsub("\n", '⏎') }
|
|
24
|
+
|
|
25
|
+
selected_index = nil
|
|
26
|
+
::IO.popen("fzf --tac --reverse --border --query='#{line}' --with-nth=1 --delimiter=$'\\t'", 'r+') do |io|
|
|
27
|
+
display.each_with_index { |d, i| io.puts "#{d}\t#{i}" }
|
|
28
|
+
io.close_write
|
|
29
|
+
result = io.read.strip
|
|
30
|
+
selected_index = result.split("\t").last.to_i unless result.empty?
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
selected_text = selected_index ? filtered[selected_index] : whole_buffer
|
|
34
|
+
reset_line
|
|
35
|
+
insert_multiline_text(selected_text)
|
|
36
|
+
$stdout.write prompt_list.last
|
|
37
|
+
if selected_text.include?("\n")
|
|
38
|
+
$stdout.write selected_text.split("\n").last
|
|
39
|
+
else
|
|
40
|
+
$stdout.write line
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.install
|
|
47
|
+
return unless defined?(Reline::LineEditor)
|
|
48
|
+
return if Reline::LineEditor < Methods
|
|
49
|
+
|
|
50
|
+
Reline::LineEditor.prepend(Methods)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'reline'
|
|
4
|
+
require_relative 'packages/completion'
|
|
5
|
+
require_relative 'packages/clipboard'
|
|
6
|
+
require_relative 'packages/history'
|
|
7
|
+
|
|
8
|
+
module RelinePac
|
|
9
|
+
# Packages contains all Reline extensions and their default keybindings.
|
|
10
|
+
module Packages
|
|
11
|
+
DEFAULT_KEYBINDS = {
|
|
12
|
+
"\C-y" => :pbpaste,
|
|
13
|
+
"\C-k" => :pbcopy_kill,
|
|
14
|
+
"\C-r" => :fzf_history,
|
|
15
|
+
"\C-n" => :completion_next,
|
|
16
|
+
"\C-p" => :completion_prev
|
|
17
|
+
}.freeze
|
|
18
|
+
|
|
19
|
+
def self.install_all
|
|
20
|
+
[Completion, Clipboard, History].each(&:install)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/reline_pac.rb
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'reline'
|
|
4
|
+
require_relative 'reline_pac/version'
|
|
5
|
+
require_relative 'reline_pac/packages'
|
|
6
|
+
require_relative 'reline_pac/config'
|
|
7
|
+
|
|
8
|
+
# RelinePac provides Reline extensions for completion, history search, and clipboard helpers.
|
|
9
|
+
module RelinePac
|
|
10
|
+
class Error < StandardError; end
|
|
11
|
+
|
|
12
|
+
def self.configure
|
|
13
|
+
config = Config.new
|
|
14
|
+
yield config if block_given?
|
|
15
|
+
config
|
|
16
|
+
end
|
|
17
|
+
end
|
data/sig/reline_pac.rbs
ADDED
metadata
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: reline_pac
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- mizuki-y
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: reline
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: 0.5.10
|
|
19
|
+
- - "<"
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: 0.7.0
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: 0.5.10
|
|
29
|
+
- - "<"
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: 0.7.0
|
|
32
|
+
description: ''
|
|
33
|
+
email:
|
|
34
|
+
- mizuki-y@syati.info
|
|
35
|
+
executables: []
|
|
36
|
+
extensions: []
|
|
37
|
+
extra_rdoc_files: []
|
|
38
|
+
files:
|
|
39
|
+
- CHANGELOG.md
|
|
40
|
+
- LICENSE.txt
|
|
41
|
+
- lib/reline_pac.rb
|
|
42
|
+
- lib/reline_pac/config.rb
|
|
43
|
+
- lib/reline_pac/packages.rb
|
|
44
|
+
- lib/reline_pac/packages/clipboard.rb
|
|
45
|
+
- lib/reline_pac/packages/completion.rb
|
|
46
|
+
- lib/reline_pac/packages/history.rb
|
|
47
|
+
- lib/reline_pac/version.rb
|
|
48
|
+
- sig/reline_pac.rbs
|
|
49
|
+
homepage: https://github.com/Syati/reline_pac
|
|
50
|
+
licenses:
|
|
51
|
+
- MIT
|
|
52
|
+
metadata:
|
|
53
|
+
homepage_uri: https://github.com/Syati/reline_pac#readme
|
|
54
|
+
changelog_uri: https://github.com/Syati/reline_pac/blob/main/CHANGELOG.md
|
|
55
|
+
bug_tracker_uri: https://github.com/Syati/reline_pac/issues
|
|
56
|
+
source_code_uri: https://github.com/Syati/reline_pac
|
|
57
|
+
rubygems_mfa_required: 'true'
|
|
58
|
+
rdoc_options: []
|
|
59
|
+
require_paths:
|
|
60
|
+
- lib
|
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
|
+
requirements:
|
|
63
|
+
- - ">="
|
|
64
|
+
- !ruby/object:Gem::Version
|
|
65
|
+
version: 3.3.10
|
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
|
+
requirements:
|
|
68
|
+
- - ">="
|
|
69
|
+
- !ruby/object:Gem::Version
|
|
70
|
+
version: '0'
|
|
71
|
+
requirements: []
|
|
72
|
+
rubygems_version: 3.6.9
|
|
73
|
+
specification_version: 4
|
|
74
|
+
summary: Reline extensions adding completion navigation, fzf history search, and macOS
|
|
75
|
+
clipboard helpers
|
|
76
|
+
test_files: []
|