ruby-shell 0.4 → 0.5
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 +35 -33
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43147c77abd46c4331dc8cf1c7ed4902f2849c7d11a67f00309ac45da5211c55
|
4
|
+
data.tar.gz: 99926b773d53e5b7302a954d62eb3f766ef6caf0c6837cfd77dbdabe4f6a7132
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f53b1c639d01623da942f8255bbfe3b32a53b95faf693c18a4520ac5541c3937a073e67cdd0cee5c2b3b24d71805ca412a45293cd85311bc90c1499af11ba271
|
7
|
+
data.tar.gz: a7c9b7d2255c62169b6cbf3b019f49a61843e3b0051836863c495278b69ce121b99b57208aea75e35a6d5d2b33085cd770644383d7505f3361501e6941aebed2
|
data/bin/rsh
CHANGED
@@ -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.5"
|
18
18
|
|
19
19
|
# MODULES, CLASSES AND EXTENSIONS
|
20
20
|
class String # Add coloring to strings (with escaping for Readline)
|
@@ -315,21 +315,28 @@ def tabselect(ary) # Let user select from the incoming array
|
|
315
315
|
@c_row, @c_col = @c.pos
|
316
316
|
chr = ""
|
317
317
|
i = 0
|
318
|
-
ary.length < 5 ? l = ary.length : l = 5
|
318
|
+
ary.length - i < 5 ? l = ary.length - i : l = 5
|
319
319
|
while chr != "ENTER"
|
320
320
|
@c.clear_screen_down
|
321
321
|
l.times do |x|
|
322
|
+
tl = @tabsearch.length
|
322
323
|
if x == 0
|
323
324
|
@c.clear_line
|
324
|
-
|
325
|
-
|
326
|
-
tabline = "#{@prompt}#{tabstart}#{@tabsearch.c(@c_tabselect)}#{tabchoice}#{@tabend}"
|
325
|
+
tabchoice = ary[i].sub(/(.*?)[ ,].*/, '\1')
|
326
|
+
tabline = "#{@prompt}#{cmd_check(@tabstr)}#{tabchoice.c(@c_tabselect)}#{@tabend}"
|
327
327
|
print tabline # Full command line
|
328
|
-
@c_col = @pos0 + @tabstr.length +
|
328
|
+
@c_col = @pos0 + @tabstr.length + tabchoice.length
|
329
329
|
nextline
|
330
|
-
|
330
|
+
sel0 = " " + ary[i][0...tl]
|
331
|
+
sel1 = ary[i][tl...].c(@c_tabselect)
|
332
|
+
print sel0 + sel1 # Top option selected
|
331
333
|
else
|
332
|
-
|
334
|
+
begin
|
335
|
+
opt0 = " " + ary[i+x][0...tl]
|
336
|
+
opt1 = ary[i+x][tl...].c(@c_taboption)
|
337
|
+
print opt0 + opt1 # Next option unselected
|
338
|
+
rescue
|
339
|
+
end
|
333
340
|
end
|
334
341
|
nextline
|
335
342
|
end
|
@@ -468,39 +475,34 @@ loop do
|
|
468
475
|
@cmd = getstr # Main work is here
|
469
476
|
hist_clean # Clean up the history
|
470
477
|
@cmd = "ls" if @cmd == "" # Default to ls when no command is given
|
471
|
-
print "\n"
|
478
|
+
print "\n"; @c.clear_screen_down
|
472
479
|
if @cmd == "r" # Integration with rtfm (https://github.com/isene/RTFM)
|
473
480
|
File.write("/tmp/.rshpwd", Dir.pwd)
|
474
481
|
system("rtfm /tmp/.rshpwd")
|
475
482
|
Dir.chdir(File.read("/tmp/.rshpwd"))
|
476
483
|
next
|
477
484
|
end
|
478
|
-
begin
|
485
|
+
begin
|
479
486
|
if @cmd.match(/^\s*:/) # Ruby commands are prefixed with ":"
|
480
487
|
eval(@cmd[1..-1])
|
481
|
-
else
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
end
|
500
|
-
rescue
|
501
|
-
if File.exist?(@cmd) # Try to open file with user's editor
|
502
|
-
system("#{ENV['EDITOR']} #{@cmd}")
|
503
|
-
end
|
488
|
+
else # Execute command
|
489
|
+
@cmd.sub!(/^cd (\S*).*/, '\1')
|
490
|
+
@cmd = Dir.home if @cmd == "~"
|
491
|
+
dir = @cmd.strip.sub(/~/, Dir.home)
|
492
|
+
Dir.chdir(dir) if Dir.exists?(dir)
|
493
|
+
ca = @nick.transform_keys {|k| /((^\K\s*\K)|(\|\K\s*\K))\b(?<!-)#{Regexp.escape k}\b/}
|
494
|
+
@cmd = @cmd.gsub(Regexp.union(ca.keys), @nick)
|
495
|
+
ga = @gnick.transform_keys {|k| /\b#{Regexp.escape k}\b/}
|
496
|
+
@cmd = @cmd.gsub(Regexp.union(ga.keys), @gnick)
|
497
|
+
puts "#{Time.now.strftime("%H:%M:%S")}: #{@cmd}".c(@c_stamp)
|
498
|
+
if @cmd == "fzf" # fzf integration (https://github.com/junegunn/fzf)
|
499
|
+
res = `#{@cmd}`.chomp
|
500
|
+
Dir.chdir(File.dirname(res))
|
501
|
+
else
|
502
|
+
if File.exist?(@cmd) # Try to open file with user's editor
|
503
|
+
system("#{ENV['EDITOR']} #{@cmd}")
|
504
|
+
elsif system(@cmd) # Try execute the command
|
505
|
+
else puts "No such command: #{@cmd}"
|
504
506
|
end
|
505
507
|
end
|
506
508
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-shell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geir Isene
|
@@ -11,7 +11,8 @@ cert_chain: []
|
|
11
11
|
date: 2023-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'A shell written in Ruby with extensive tab completions, aliases/nicks,
|
14
|
-
history, syntax highlighting and theming. New in 0.
|
14
|
+
history, syntax highlighting and theming. New in 0.5: Code clean-up. Even better
|
15
|
+
tab completion.'
|
15
16
|
email: g@isene.com
|
16
17
|
executables:
|
17
18
|
- rsh
|