ruby-shell 2.5 → 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 +29 -9
- 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
|
|
@@ -260,12 +268,16 @@ def getstr # A custom Readline-like function
|
|
|
260
268
|
@pos = 0
|
|
261
269
|
chr = ""
|
|
262
270
|
@history.unshift("")
|
|
271
|
+
@row0, p = @c.pos
|
|
263
272
|
while chr != "ENTER" # Keep going with readline until user presses ENTER
|
|
264
273
|
@ci = nil
|
|
265
274
|
lift = false
|
|
266
275
|
right = false
|
|
276
|
+
# The actual printing og the command line
|
|
277
|
+
@c.row(@row0)
|
|
267
278
|
@c.clear_line
|
|
268
279
|
print @prompt
|
|
280
|
+
@c.clear_screen_down
|
|
269
281
|
row, @pos0 = @c.pos
|
|
270
282
|
#@history[0] = "" if @history[0].nil?
|
|
271
283
|
print cmd_check(@history[0])
|
|
@@ -278,7 +290,15 @@ def getstr # A custom Readline-like function
|
|
|
278
290
|
print @ciprompt.c(@c_stamp)
|
|
279
291
|
right = true
|
|
280
292
|
end
|
|
281
|
-
@
|
|
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
|
|
282
302
|
chr = getchr
|
|
283
303
|
case chr
|
|
284
304
|
when 'C-G', 'C-C'
|
|
@@ -311,6 +331,8 @@ def getstr # A custom Readline-like function
|
|
|
311
331
|
end
|
|
312
332
|
lift = false
|
|
313
333
|
end
|
|
334
|
+
@c.row(@row0)
|
|
335
|
+
@c.clear_screen_down
|
|
314
336
|
when 'DOWN' # Go down in history
|
|
315
337
|
if lift
|
|
316
338
|
@history.unshift("")
|
|
@@ -330,6 +352,8 @@ def getstr # A custom Readline-like function
|
|
|
330
352
|
@pos = @history[0].length
|
|
331
353
|
end
|
|
332
354
|
lift = false
|
|
355
|
+
@c.row(@row0)
|
|
356
|
+
@c.clear_screen_down
|
|
333
357
|
when 'RIGHT' # Move right on the readline
|
|
334
358
|
if right
|
|
335
359
|
if lift
|
|
@@ -356,6 +380,7 @@ def getstr # A custom Readline-like function
|
|
|
356
380
|
@history[0][@pos] = ""
|
|
357
381
|
end
|
|
358
382
|
lift = true
|
|
383
|
+
@c.clear_line_after
|
|
359
384
|
when 'WBACK' # Delete one word to the left (Ctrl-W)
|
|
360
385
|
unless @pos == @pos0
|
|
361
386
|
until @history[0][@pos - 1] == " " or @pos == 0
|
|
@@ -368,6 +393,7 @@ def getstr # A custom Readline-like function
|
|
|
368
393
|
end
|
|
369
394
|
end
|
|
370
395
|
lift = true
|
|
396
|
+
@c.clear_line_after
|
|
371
397
|
when 'C-Y' # Copy command line to primary selection
|
|
372
398
|
system("echo -n '#{@history[0]}' | xclip")
|
|
373
399
|
puts "\n#{Time.now.strftime("%H:%M:%S")}: Copied to primary selection (paste with middle buttoni)".c(@c_stamp)
|
|
@@ -406,7 +432,7 @@ def getstr # A custom Readline-like function
|
|
|
406
432
|
@pos += 1
|
|
407
433
|
end
|
|
408
434
|
end
|
|
409
|
-
|
|
435
|
+
#@c.col(@pos0 + @history[0].length)
|
|
410
436
|
@c.clear_screen_down
|
|
411
437
|
end
|
|
412
438
|
def tab(type)
|
|
@@ -545,17 +571,11 @@ def hist_clean # Clean up @history
|
|
|
545
571
|
end
|
|
546
572
|
def cmd_check(str) # Check if each element on the readline matches commands, nicks, paths; color them
|
|
547
573
|
return if str.nil?
|
|
548
|
-
#elements = str.scan(/[^\s']+|'.+?'/)
|
|
549
|
-
#elements.map! do |el|
|
|
550
|
-
# .... the ifs
|
|
551
|
-
#elements.join(" ")
|
|
552
574
|
str.gsub(/(?:\S'[^']*'|[^ '])+/) do |el|
|
|
553
575
|
if @exe.include?(el)
|
|
554
576
|
el.c(@c_cmd)
|
|
555
577
|
elsif el == "cd"
|
|
556
578
|
el.c(@c_cmd)
|
|
557
|
-
elsif File.executable?(el.gsub("'", ""))
|
|
558
|
-
el.c(@c_cmd)
|
|
559
579
|
elsif File.exist?(el.gsub("'", ""))
|
|
560
580
|
el.c(@c_path)
|
|
561
581
|
elsif @nick.include?(el)
|
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
|