ruby-shell 3.6.18 → 3.6.20

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rsh +28 -12
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2e9ecc77e9137be0869ab5108ca168b9af1fe7482f7c48db56d222381f3e0c2b
4
- data.tar.gz: ffb83039ed726fdc1484e9c4d283525205dc39cd8a346c981005da8f14c3e5ac
3
+ metadata.gz: c870824b26622fb9ac7d29cd504a40d8cd1078450c237d622f6e8de83b261067
4
+ data.tar.gz: 24cc04b6488f8b1aa9b2a9ea9e7435fb862a6471a0f985d1734ae0f24f26d943
5
5
  SHA512:
6
- metadata.gz: a5bd6cc37c73511c6267b246c86048f55a48bb6054d9e2242b958f5d6a164a81d04c090b6c0ff053afa84e4ac64fcac2b4e36cae11926f45f7553af1461a27ee
7
- data.tar.gz: abe9d8a5fcb1738492c99301c2f2171b4abb5450a4c24f79294b2eebe98a12e7962557e13d0bd79f068423d970223ea4af94358f6f7d40a577af81315efee2e3
6
+ metadata.gz: d7666d9348df0d4d6fe53cc846fab95d9ad18ddabc06963acdef429a24c0e31371f2d97d757f788a07cf7b5e1fc73fd4dcb38438e6cdcc8af975dceaf504cc5b
7
+ data.tar.gz: 77573a08927e688ba0f71945ee0f4ec7f3ada7e0054733b2bf81213949b208e71327fcd953ed89c610b092ba926929f7873be91979ae9d0ebf8515f922578c50
data/bin/rsh CHANGED
@@ -8,22 +8,29 @@
8
8
  # Web_site: http://isene.com/
9
9
  # Github: https://github.com/isene/rsh
10
10
  # License: Public domain
11
- @version = "3.6.18" # Fix nick deletion and hyphenated command handling
11
+ @version = "3.6.20" # Performance: cache color escapes, pre-compile regex
12
12
 
13
13
  # MODULES, CLASSES AND EXTENSIONS
14
14
  class String # Add coloring to strings (with escaping for Readline)
15
- def c(code); color(self, "\001\e[38;5;#{code}m\002"); end # Color code
16
- def b; color(self, "\001\e[1m\002"); end # Bold
17
- def i; color(self, "\001\e[3m\002"); end # Italic
18
- def u; color(self, "\001\e[4m\002"); end # Underline
19
- def l; color(self, "\001\e[5m\002"); end # Blink
20
- def r; color(self, "\001\e[7m\002"); end # Reverse
21
- def color(text, color_code) "#{color_code}#{text}\001\e[0m\002" end
15
+ COLOR_CACHE = Hash.new { |h, k| h[k] = "\001\e[38;5;#{k}m\002".freeze }
16
+ RESET_CODE = "\001\e[0m\002".freeze
17
+ BOLD_CODE = "\001\e[1m\002".freeze
18
+ ITALIC_CODE = "\001\e[3m\002".freeze
19
+ ULINE_CODE = "\001\e[4m\002".freeze
20
+ BLINK_CODE = "\001\e[5m\002".freeze
21
+ REV_CODE = "\001\e[7m\002".freeze
22
+ def c(code); "#{COLOR_CACHE[code]}#{self}#{RESET_CODE}"; end # Color code
23
+ def b; "#{BOLD_CODE}#{self}#{RESET_CODE}"; end # Bold
24
+ def i; "#{ITALIC_CODE}#{self}#{RESET_CODE}"; end # Italic
25
+ def u; "#{ULINE_CODE}#{self}#{RESET_CODE}"; end # Underline
26
+ def l; "#{BLINK_CODE}#{self}#{RESET_CODE}"; end # Blink
27
+ def r; "#{REV_CODE}#{self}#{RESET_CODE}"; end # Reverse
22
28
  end
23
29
  module Cursor # Terminal cursor movement ANSI codes (thanks to https://github.com/piotrmurach/tty-cursor)
24
30
  module_function
25
31
  ESC = "\e".freeze
26
32
  CSI = "\e[".freeze
33
+ POS_RE = /(?<row>\d+);(?<col>\d+)/.freeze
27
34
  def save # Save current position
28
35
  print(Gem.win_platform? ? CSI + 's' : ESC + '7')
29
36
  end
@@ -44,7 +51,7 @@ module Cursor # Terminal cursor movement ANSI codes (thanks to https://github.co
44
51
  # Not a TTY, return default values
45
52
  return 25, 80
46
53
  end
47
- m = res.match /(?<row>\d+);(?<col>\d+)/
54
+ m = res.match POS_RE
48
55
  return m ? [m[:row].to_i, m[:col].to_i] : [25, 80]
49
56
  end
50
57
  def rowget
@@ -562,9 +569,18 @@ def getstr # A custom Readline-like function
562
569
  end
563
570
  end
564
571
  lift = true
565
- when 'C-Y' # Copy command line to primary selection
566
- IO.popen('xclip', 'w') { |io| io.write(@history[0]) }
567
- puts "\n#{Time.now.strftime("%H:%M:%S")}: Copied to primary selection (paste with middle buttoni)".c(@c_stamp)
572
+ when 'C-Y' # Copy to clipboard
573
+ if @history[0].empty? && @history[1]
574
+ # Empty line: copy last command to clipboard
575
+ IO.popen('xclip -selection clipboard', 'w') { |io| io.write(@history[1]) } rescue nil
576
+ IO.popen('xclip -selection primary', 'w') { |io| io.write(@history[1]) } rescue nil
577
+ puts "\n#{Time.now.strftime("%H:%M:%S")}: Last command copied to clipboard".c(@c_stamp)
578
+ else
579
+ # Non-empty line: copy current line to clipboard
580
+ IO.popen('xclip -selection clipboard', 'w') { |io| io.write(@history[0]) } rescue nil
581
+ IO.popen('xclip -selection primary', 'w') { |io| io.write(@history[0]) } rescue nil
582
+ puts "\n#{Time.now.strftime("%H:%M:%S")}: Copied to clipboard".c(@c_stamp)
583
+ end
568
584
  when 'C-Z' # Suspend current process (background job)
569
585
  if @current_pid
570
586
  puts "\n[#{@job_id}] Suspended #{@current_pid}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-shell
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.6.18
4
+ version: 3.6.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-03-23 00:00:00.000000000 Z
11
+ date: 2026-03-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'A shell written in Ruby with extensive tab completions, aliases/nicks,
14
14
  history, syntax highlighting, theming, auto-cd, auto-opening files and more. UPDATE