ruby-shell 2.3 → 2.6
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/rsh +49 -20
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c5913a47ce444d23c974bea7579acfa7413ea40c127d8fe4f5fe22ff788b0ba
|
4
|
+
data.tar.gz: 9dc3737af78ee22e40f630f69e9ed60942edbd94d5bdbc08515b2e7692529fdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef49ff226a32103a6a345b5087f0b54776efbd02e4c7435dbb3e4ef2aac439c3221c6f8b4b361a7b38fecdc40b9301bdd6a247c7716353e69b8b8dfdf94dc1b0
|
7
|
+
data.tar.gz: 519693833b835995ab7cdd9f7c4c089c611646eb46d195a9f5dc7aa4565190c23f3e5303624169336c43711753173b6197db47f32404b02052031ad626778abb
|
data/bin/rsh
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
# Web_site: http://isene.com/
|
9
9
|
# Github: https://github.com/isene/rsh
|
10
10
|
# License: Public domain
|
11
|
-
@version = "2.
|
11
|
+
@version = "2.6"
|
12
12
|
|
13
13
|
# MODULES, CLASSES AND EXTENSIONS
|
14
14
|
class String # Add coloring to strings (with escaping for Readline)
|
@@ -42,6 +42,14 @@ module Cursor # Terminal cursor movement ANSI codes (thanks to https://github.co
|
|
42
42
|
m = res.match /(?<row>\d+);(?<col>\d+)/
|
43
43
|
return m[:row].to_i, m[:col].to_i
|
44
44
|
end
|
45
|
+
def rowget
|
46
|
+
row, col = self.pos
|
47
|
+
return row
|
48
|
+
end
|
49
|
+
def colget
|
50
|
+
row, col = self.pos
|
51
|
+
return col
|
52
|
+
end
|
45
53
|
def up(n = nil) # Move cursor up by n
|
46
54
|
print(CSI + "#{(n || 1)}A")
|
47
55
|
end
|
@@ -118,6 +126,7 @@ begin # Initialization
|
|
118
126
|
@nick = {} # Initiate alias/nick hash
|
119
127
|
@gnick = {} # Initiate generic/global alias/nick hash
|
120
128
|
@history = [] # Initiate history array
|
129
|
+
@exe = []
|
121
130
|
# Paths
|
122
131
|
@user = Etc.getpwuid(Process.euid).name # For use in @prompt
|
123
132
|
@path = ENV["PATH"].split(":") # Get paths
|
@@ -259,12 +268,16 @@ def getstr # A custom Readline-like function
|
|
259
268
|
@pos = 0
|
260
269
|
chr = ""
|
261
270
|
@history.unshift("")
|
271
|
+
@row0, p = @c.pos
|
262
272
|
while chr != "ENTER" # Keep going with readline until user presses ENTER
|
263
273
|
@ci = nil
|
264
274
|
lift = false
|
265
275
|
right = false
|
276
|
+
# The actual printing og the command line
|
277
|
+
@c.row(@row0)
|
266
278
|
@c.clear_line
|
267
279
|
print @prompt
|
280
|
+
@c.clear_screen_down
|
268
281
|
row, @pos0 = @c.pos
|
269
282
|
#@history[0] = "" if @history[0].nil?
|
270
283
|
print cmd_check(@history[0])
|
@@ -277,7 +290,15 @@ def getstr # A custom Readline-like function
|
|
277
290
|
print @ciprompt.c(@c_stamp)
|
278
291
|
right = true
|
279
292
|
end
|
280
|
-
@
|
293
|
+
c_col = @pos0 + @pos
|
294
|
+
c_row = @row0 + c_col/(@maxcol)
|
295
|
+
c_col == 0 ? @c.row(c_row + 1) : @c.row(c_row)
|
296
|
+
if c_col.modulo(@maxcol) == 0
|
297
|
+
@c.col(c_col)
|
298
|
+
@c.row(@c.rowget - 1)
|
299
|
+
else
|
300
|
+
@c.col(c_col.modulo(@maxcol))
|
301
|
+
end
|
281
302
|
chr = getchr
|
282
303
|
case chr
|
283
304
|
when 'C-G', 'C-C'
|
@@ -310,6 +331,8 @@ def getstr # A custom Readline-like function
|
|
310
331
|
end
|
311
332
|
lift = false
|
312
333
|
end
|
334
|
+
@c.row(@row0)
|
335
|
+
@c.clear_screen_down
|
313
336
|
when 'DOWN' # Go down in history
|
314
337
|
if lift
|
315
338
|
@history.unshift("")
|
@@ -329,6 +352,8 @@ def getstr # A custom Readline-like function
|
|
329
352
|
@pos = @history[0].length
|
330
353
|
end
|
331
354
|
lift = false
|
355
|
+
@c.row(@row0)
|
356
|
+
@c.clear_screen_down
|
332
357
|
when 'RIGHT' # Move right on the readline
|
333
358
|
if right
|
334
359
|
if lift
|
@@ -355,6 +380,7 @@ def getstr # A custom Readline-like function
|
|
355
380
|
@history[0][@pos] = ""
|
356
381
|
end
|
357
382
|
lift = true
|
383
|
+
@c.clear_line_after
|
358
384
|
when 'WBACK' # Delete one word to the left (Ctrl-W)
|
359
385
|
unless @pos == @pos0
|
360
386
|
until @history[0][@pos - 1] == " " or @pos == 0
|
@@ -367,6 +393,7 @@ def getstr # A custom Readline-like function
|
|
367
393
|
end
|
368
394
|
end
|
369
395
|
lift = true
|
396
|
+
@c.clear_line_after
|
370
397
|
when 'C-Y' # Copy command line to primary selection
|
371
398
|
system("echo -n '#{@history[0]}' | xclip")
|
372
399
|
puts "\n#{Time.now.strftime("%H:%M:%S")}: Copied to primary selection (paste with middle buttoni)".c(@c_stamp)
|
@@ -405,7 +432,7 @@ def getstr # A custom Readline-like function
|
|
405
432
|
@pos += 1
|
406
433
|
end
|
407
434
|
end
|
408
|
-
|
435
|
+
#@c.col(@pos0 + @history[0].length)
|
409
436
|
@c.clear_screen_down
|
410
437
|
end
|
411
438
|
def tab(type)
|
@@ -434,16 +461,12 @@ def tab(type)
|
|
434
461
|
hlp = hlp.reject{|h| /-</ =~ h}
|
435
462
|
@tabarray = hlp
|
436
463
|
when "all" # Handle all other tab completions
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
exe.sort!
|
444
|
-
exe.prepend(*@nick.keys) # Add nicks
|
445
|
-
exe.prepend(*@gnick.keys) # Add gnicks
|
446
|
-
compl = exe.select {|s| s =~ Regexp.new(@tabstr)} # Select only that which matches so far
|
464
|
+
ex = []
|
465
|
+
ex += @exe
|
466
|
+
ex.sort!
|
467
|
+
ex.prepend(*@nick.keys) # Add nicks
|
468
|
+
ex.prepend(*@gnick.keys) # Add gnicks
|
469
|
+
compl = ex.select {|s| s =~ Regexp.new(@tabstr)} # Select only that which matches so far
|
447
470
|
fdir = @tabstr + "*"
|
448
471
|
compl.prepend(*Dir.glob(fdir)).map! do |e|
|
449
472
|
if e =~ /(?<!\\) /
|
@@ -549,18 +572,18 @@ end
|
|
549
572
|
def cmd_check(str) # Check if each element on the readline matches commands, nicks, paths; color them
|
550
573
|
return if str.nil?
|
551
574
|
str.gsub(/(?:\S'[^']*'|[^ '])+/) do |el|
|
552
|
-
if @
|
575
|
+
if @exe.include?(el)
|
576
|
+
el.c(@c_cmd)
|
577
|
+
elsif el == "cd"
|
578
|
+
el.c(@c_cmd)
|
579
|
+
elsif File.exist?(el.gsub("'", ""))
|
580
|
+
el.c(@c_path)
|
581
|
+
elsif @nick.include?(el)
|
553
582
|
el.c(@c_nick)
|
554
583
|
elsif el == "r" or el == "f"
|
555
584
|
el.c(@c_nick)
|
556
585
|
elsif @gnick.include?(el)
|
557
586
|
el.c(@c_gnick)
|
558
|
-
elsif File.exist?(el.gsub("'", ""))
|
559
|
-
el.c(@c_path)
|
560
|
-
elsif system "which #{el}", %i[out err] => File::NULL
|
561
|
-
el.c(@c_cmd)
|
562
|
-
elsif el == "cd"
|
563
|
-
el.c(@c_cmd)
|
564
587
|
elsif el[0] == "-"
|
565
588
|
el.c(@c_switch)
|
566
589
|
else
|
@@ -669,6 +692,12 @@ loop do
|
|
669
692
|
@prompt.gsub!(/#{Dir.home}/, '~') # Simplify path in prompt
|
670
693
|
system("printf \"\033]0;rsh: #{Dir.pwd}\007\"") # Set Window title to path
|
671
694
|
@history[0] = "" unless @history[0]
|
695
|
+
@exe = []
|
696
|
+
@path.each do |p| # Add all executables in @path
|
697
|
+
Dir.glob(p).each do |c|
|
698
|
+
@exe.append(File.basename(c)) if File.executable?(c) and not Dir.exist?(c)
|
699
|
+
end
|
700
|
+
end
|
672
701
|
getstr # Main work is here
|
673
702
|
@cmd = @history[0]
|
674
703
|
@dirs.unshift(Dir.pwd)
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-shell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '2.
|
4
|
+
version: '2.6'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geir Isene
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-30 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. In
|
15
15
|
continual development. New in 2.0: Full rewrite of tab completion engine. Lots of
|
16
|
-
other bug fixes. 2.
|
16
|
+
other bug fixes. 2.6: Handling line longer than terminal width.'
|
17
17
|
email: g@isene.com
|
18
18
|
executables:
|
19
19
|
- rsh
|