ruby-shell 0.8 → 0.9
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/README.md +3 -0
- data/bin/rsh +31 -10
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2eb807ee53179bcbc57da83b9bdbf7d46d524ad01d384c450df00c0036e636f1
|
4
|
+
data.tar.gz: '0595692866bfd1acf9afda02e157232d7e86701063cf7e5deff2654fe9a1c0d0'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e9349dee0b04e6f9e0d91afcb4f60d90111249b80d3820b75a4efa16fdcea26e702ba64c895f84c0e903ec018748f8a9258a369015097e9e55f81a9ee1d7d40
|
7
|
+
data.tar.gz: d0ba07abb7b5490609691cafa88fc4c4299823ae91990daab7d5616c69535b2a9e69269141bf93e45721369eaaa93defd496b94101641d2c143b4631134af02f
|
data/README.md
CHANGED
@@ -19,6 +19,9 @@ Or simply `gem install ruby-shell`.
|
|
19
19
|
* Syntax highlighting, matching nicks, system commands and valid dirs/files
|
20
20
|
* Tab completions for nicks, system commands, command switches and dirs/files
|
21
21
|
* Tab completion presents matches in a list to pick from
|
22
|
+
* When you start to write a command, rsh will suggest the first match in the
|
23
|
+
history and present that in "toned down" letters - press the arrow right key
|
24
|
+
to accept the suggestion.
|
22
25
|
* History with simple editing
|
23
26
|
* Config file (`.rshrc`) updates on exit
|
24
27
|
* Set of simple rsh specific commands like `nick`, `nick?`, `history` and `rmhistory`
|
data/bin/rsh
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# encoding: utf-8
|
3
3
|
#
|
4
4
|
# SCRIPT INFO
|
5
|
-
# Name:
|
5
|
+
# Name: rsh - Ruby SHell
|
6
6
|
# Language: Pure Ruby, best viewed in VIM
|
7
7
|
# Author: Geir Isene <g@isene.com>
|
8
8
|
# Web_site: http://isene.com/
|
9
|
-
# Github: https://github.com/isene/
|
9
|
+
# Github: https://github.com/isene/rsh
|
10
10
|
# License: I release all copyright claims. This code is in the public domain.
|
11
11
|
# Permission is granted to use, copy modify, distribute, and sell
|
12
12
|
# this software for any purpose. I make no guarantee about the
|
@@ -14,7 +14,7 @@
|
|
14
14
|
# for any damages resulting from its use. Further, I am under no
|
15
15
|
# obligation to maintain or extend this software. It is provided
|
16
16
|
# on an 'as is' basis without any expressed or implied warranty.
|
17
|
-
@version = "0.
|
17
|
+
@version = "0.9"
|
18
18
|
|
19
19
|
# MODULES, CLASSES AND EXTENSIONS
|
20
20
|
class String # Add coloring to strings (with escaping for Readline)
|
@@ -177,9 +177,10 @@ def getchr # Process key presses
|
|
177
177
|
return chr
|
178
178
|
end
|
179
179
|
def getstr # A custom Readline-like function
|
180
|
-
@stk
|
180
|
+
@stk = 0
|
181
181
|
@pos = 0
|
182
|
-
|
182
|
+
right = false
|
183
|
+
chr = ""
|
183
184
|
@history.insert(0, "")
|
184
185
|
@history_copy = @history.map(&:clone)
|
185
186
|
while chr != "ENTER" # Keep going with readline until user presses ENTER
|
@@ -188,6 +189,16 @@ def getstr # A custom Readline-like function
|
|
188
189
|
print @prompt
|
189
190
|
row, @pos0 = @c.pos
|
190
191
|
print cmd_check(text)
|
192
|
+
begin
|
193
|
+
cmpl = @history[1..].find {|e| e =~ /^#{Regexp.escape(text)}/}
|
194
|
+
if text.length > 2 and cmpl
|
195
|
+
print cmpl[text.length..].to_s.c(@c_stamp)
|
196
|
+
right = true
|
197
|
+
else
|
198
|
+
right = false
|
199
|
+
end
|
200
|
+
rescue
|
201
|
+
end
|
191
202
|
@c.col(@pos0 + @pos)
|
192
203
|
chr = getchr
|
193
204
|
return "\n" if chr == "C-G" # Ctrl-G escapes the reasdline
|
@@ -212,6 +223,10 @@ def getstr # A custom Readline-like function
|
|
212
223
|
@pos = @history_copy[@stk].length
|
213
224
|
end
|
214
225
|
when 'RIGHT' # Move right on the readline
|
226
|
+
if right
|
227
|
+
@history_copy[@stk] = cmpl
|
228
|
+
@pos = @history_copy[@stk].length
|
229
|
+
end
|
215
230
|
@pos += 1 unless @pos >= @history_copy[@stk].length
|
216
231
|
when 'LEFT' # Move left on the readline
|
217
232
|
@pos -= 1 unless @pos <= 0
|
@@ -321,6 +336,7 @@ def tab_switch(str) # TAB completion for command switches (TAB after "-")
|
|
321
336
|
end
|
322
337
|
def tab_hist(str)
|
323
338
|
sel = @history.select {|el| el =~ /#{str}/}
|
339
|
+
sel.delete("")
|
324
340
|
hist = tabselect(sel, true)
|
325
341
|
@tabsearch = hist if hist
|
326
342
|
@pos = @tabstr.length + @tabsearch.length if hist
|
@@ -357,7 +373,7 @@ def tabselect(ary, hist=false) # Let user select from the incoming array
|
|
357
373
|
case chr
|
358
374
|
when 'C-G', 'C-C'
|
359
375
|
@c.clear_screen_down
|
360
|
-
return
|
376
|
+
return @tabsearch
|
361
377
|
when 'DOWN'
|
362
378
|
i += 1 unless i > ary.length - 2
|
363
379
|
when 'UP'
|
@@ -365,7 +381,11 @@ def tabselect(ary, hist=false) # Let user select from the incoming array
|
|
365
381
|
when 'TAB'
|
366
382
|
chr = "ENTER"
|
367
383
|
when 'BACK'
|
368
|
-
|
384
|
+
if @tabsearch == ''
|
385
|
+
@c.clear_screen_down
|
386
|
+
return ""
|
387
|
+
end
|
388
|
+
@tabsearch.chop!
|
369
389
|
hist ? tab_hist(@tabsearch) : tab_all(@tabsearch)
|
370
390
|
return @tabsearch
|
371
391
|
when /^[[:print:]]$/
|
@@ -499,8 +519,9 @@ loop do
|
|
499
519
|
if @cmd.match(/^\s*:/) # Ruby commands are prefixed with ":"
|
500
520
|
begin
|
501
521
|
eval(@cmd[1..-1])
|
502
|
-
rescue
|
503
|
-
|
522
|
+
rescue StandardError => err
|
523
|
+
#rescue Exception => err
|
524
|
+
puts "\n#{err}"
|
504
525
|
end
|
505
526
|
else # Execute command
|
506
527
|
@cmd.sub!(/^cd (\S*).*/, '\1')
|
@@ -526,7 +547,7 @@ loop do
|
|
526
547
|
end
|
527
548
|
end
|
528
549
|
rescue StandardError => err # Throw error nicely
|
529
|
-
puts "#{err}"
|
550
|
+
puts "\n#{err}"
|
530
551
|
end
|
531
552
|
end
|
532
553
|
|
metadata
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-shell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.9'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geir Isene
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-02 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 and more. In continual development. New in
|
15
|
-
0.
|
15
|
+
0.9: Added the feature to suggdest the first match in history when you start writing
|
16
|
+
a command - press the right arrow key to accept.'
|
16
17
|
email: g@isene.com
|
17
18
|
executables:
|
18
19
|
- rsh
|