ruby-shell 0.25 → 1.0
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 +28 -19
- metadata +3 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b401cd958da9d499c8f83e10c0668100c8a37fe2ceada25115643c508ba79153
|
|
4
|
+
data.tar.gz: 14c6c94195fb174413aa92aa9b96a00dd4b7160c0321a5f12906734dbbde96f3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aa7dadcea2331c1d524be7a987e4e6f7ed0a38e3ad8dbef5f5c4152011bb7ea9314ba4f7b73dbfc45e8a18537413e291283bdfe52b68095aeb6c7572176d385d
|
|
7
|
+
data.tar.gz: 160864330f697225deb7c391491266c82b1289b220724ef974609f13095bc8192196779ea99326d49524875d0da53aa2ee14d8db81b9c0308834442b09792426
|
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 = "1.0"
|
|
18
18
|
|
|
19
19
|
# MODULES, CLASSES AND EXTENSIONS
|
|
20
20
|
class String # Add coloring to strings (with escaping for Readline)
|
|
@@ -270,7 +270,7 @@ def getstr # A custom Readline-like function
|
|
|
270
270
|
case chr
|
|
271
271
|
when 'C-G', 'C-C'
|
|
272
272
|
@history[0] = ""
|
|
273
|
-
|
|
273
|
+
@pos = 0
|
|
274
274
|
when 'C-E' # Ctrl-C exits gracefully but without updating .rshrc
|
|
275
275
|
print "\n"
|
|
276
276
|
exit
|
|
@@ -357,8 +357,13 @@ def getstr # A custom Readline-like function
|
|
|
357
357
|
when 'C-K' # Kill/delete that entry in the history
|
|
358
358
|
@history.delete_at(@stk)
|
|
359
359
|
@stk -= 1
|
|
360
|
-
@
|
|
361
|
-
|
|
360
|
+
if @stk == 0
|
|
361
|
+
@history[0] = ""
|
|
362
|
+
@pos = 0
|
|
363
|
+
else
|
|
364
|
+
@history[0] = @history[@stk].dup
|
|
365
|
+
@pos = @history[0].length
|
|
366
|
+
end
|
|
362
367
|
when 'LDEL' # Delete readline (Ctrl-U)
|
|
363
368
|
@history[0] = ""
|
|
364
369
|
@pos = 0
|
|
@@ -430,7 +435,7 @@ def tab_all(str) # TAB completion for Dirs/files, nicks and commands
|
|
|
430
435
|
end
|
|
431
436
|
def tab_switch(str) # TAB completion for command switches (TAB after "-")
|
|
432
437
|
begin
|
|
433
|
-
hlp = `#{str} --help`
|
|
438
|
+
hlp = `#{str} --help 2>/dev/null`
|
|
434
439
|
hlp = hlp.split("\n").grep(/^\s*-{1,2}[^-]/)
|
|
435
440
|
hlp = hlp.map{|h| h.sub(/^\s*/, '').sub(/^--/, ' --')}
|
|
436
441
|
switch = tabselect(hlp)
|
|
@@ -462,7 +467,7 @@ def tabselect(ary, hist=false) # Let user select from the incoming array
|
|
|
462
467
|
tl = @tabsearch.length
|
|
463
468
|
if x == 0
|
|
464
469
|
@c.clear_line
|
|
465
|
-
tabchoice = ary[i].sub(
|
|
470
|
+
tabchoice = ary[i].sub(/^ *(.*?)[ ,].*/, '\1')
|
|
466
471
|
tabline = "#{@prompt}#{cmd_check(@tabstr)}#{tabchoice.c(@c_tabselect)}#{@tabend}"
|
|
467
472
|
print tabline # Full command line
|
|
468
473
|
@c_col = @pos0 + @tabstr.length + tabchoice.length
|
|
@@ -506,7 +511,7 @@ def tabselect(ary, hist=false) # Let user select from the incoming array
|
|
|
506
511
|
@c.clear_screen_down
|
|
507
512
|
@c.row(@c_row)
|
|
508
513
|
@c.col(@c_col)
|
|
509
|
-
return ary[i]
|
|
514
|
+
return ary[i].sub(/^ */, '')
|
|
510
515
|
end
|
|
511
516
|
def nextline # Handle going to the next line in the terminal
|
|
512
517
|
row, col = @c.pos
|
|
@@ -525,6 +530,8 @@ def cmd_check(str) # Check if each element on the readline matches commands, nic
|
|
|
525
530
|
str.gsub(/\S+/) do |el|
|
|
526
531
|
if @nick.include?(el)
|
|
527
532
|
el.c(@c_nick)
|
|
533
|
+
elsif el == "r"
|
|
534
|
+
el.c(@c_nick)
|
|
528
535
|
elsif @gnick.include?(el)
|
|
529
536
|
el.c(@c_gnick)
|
|
530
537
|
elsif File.exist?(el.sub(/^~/, "/home/#{@user}"))
|
|
@@ -609,7 +616,7 @@ end
|
|
|
609
616
|
|
|
610
617
|
# INITIAL SETUP
|
|
611
618
|
begin # Load .rshrc and populate @history
|
|
612
|
-
|
|
619
|
+
trap "SIGINT" do end
|
|
613
620
|
firstrun unless File.exist?(Dir.home+'/.rshrc') # Initial loading - to get history
|
|
614
621
|
load(Dir.home+'/.rshrc')
|
|
615
622
|
ENV["SHELL"] = __FILE__
|
|
@@ -691,19 +698,21 @@ loop do
|
|
|
691
698
|
if @cmd == "f" # fzf integration (https://github.com/junegunn/fzf)
|
|
692
699
|
res = `fzf`.chomp
|
|
693
700
|
Dir.chdir(File.dirname(res))
|
|
694
|
-
|
|
695
|
-
if File.
|
|
696
|
-
|
|
697
|
-
|
|
701
|
+
elsif File.exist?(@cmd) and not File.executable?(@cmd)
|
|
702
|
+
if File.read(@cmd).force_encoding("UTF-8").valid_encoding?
|
|
703
|
+
system("#{ENV['EDITOR']} #{@cmd}") # Try open with user's editor
|
|
704
|
+
else
|
|
705
|
+
if @runmailcap
|
|
706
|
+
Thread.new { system("run-mailcap #{@cmd} 2>/dev/null") }
|
|
698
707
|
else
|
|
699
|
-
|
|
700
|
-
Thread.new { system("run-mailcap #{@cmd} 2>/dev/null") }
|
|
701
|
-
else
|
|
702
|
-
Thread.new { system("xdg-open #{@cmd} 2>/dev/null") }
|
|
703
|
-
end
|
|
708
|
+
Thread.new { system("xdg-open #{@cmd} 2>/dev/null") }
|
|
704
709
|
end
|
|
705
|
-
|
|
706
|
-
|
|
710
|
+
end
|
|
711
|
+
else
|
|
712
|
+
begin
|
|
713
|
+
puts "No such command or nick: #{@cmd}" unless system (@cmd) # Try execute the command
|
|
714
|
+
rescue StandardError => err
|
|
715
|
+
puts "\n#{err}"
|
|
707
716
|
end
|
|
708
717
|
end
|
|
709
718
|
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: '1.0'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Geir Isene
|
|
@@ -11,9 +11,8 @@ cert_chain: []
|
|
|
11
11
|
date: 2023-06-19 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, theming and more. In
|
|
15
|
-
0
|
|
16
|
-
config save.'
|
|
14
|
+
history, syntax highlighting, theming, auto-cd, auto-opening files and more. In
|
|
15
|
+
continual development. New in 1.0: Several fixes. Celebrating rsh as my sole shell.'
|
|
17
16
|
email: g@isene.com
|
|
18
17
|
executables:
|
|
19
18
|
- rsh
|