ruby-shell 2.3 → 2.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rsh +27 -18
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 430ac5700dcc8216283045a1d608e0c53982018c39797921b39eb262e8df22bb
4
- data.tar.gz: 8af1ec08df62ec8c79f1f1177ee8629fd388dbf15975a827296ec99894b77fdd
3
+ metadata.gz: e4cbdfe9d1c09e98287dff7de8cfabb7dd776fa6f7617f4a0801d17f7b463bad
4
+ data.tar.gz: cf3b1311d1891caa516b427ef065f79f3d6b23e2486f5d070111f7040a812a05
5
5
  SHA512:
6
- metadata.gz: 1182b247e8c1128e748d2c24a3f1066e10be2c0e561b50ed02df1b39cbef77450035fa383f9fdb4da50552de56b867201acb9f6e3e8797034da1c9a437dd96e2
7
- data.tar.gz: 9b461d925debaed83878c368635c4b6a3b1a1543984896501ef43d5441d4c3b67667ffe4aae2cc0958ea8c82c226e7c46834352de90b3be56c98dcb0b17ed549
6
+ metadata.gz: 673ee174f332d75d8cc0bf5a9570f18d02931e047386e23e727fb6f8ecb16a694095d59d609cc45b7438b49d5b7be4b801465398fe831f84bbc78b38287af69a
7
+ data.tar.gz: 35a0eac8a83bbf933deb101fd5e920414c59827dd43292889a300a26d0979cf1de9967acbb78c56ee332da7f605311e57bd7caba799eb82ea15b5dd3160fb3b2
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.3"
11
+ @version = "2.5"
12
12
 
13
13
  # MODULES, CLASSES AND EXTENSIONS
14
14
  class String # Add coloring to strings (with escaping for Readline)
@@ -118,6 +118,7 @@ begin # Initialization
118
118
  @nick = {} # Initiate alias/nick hash
119
119
  @gnick = {} # Initiate generic/global alias/nick hash
120
120
  @history = [] # Initiate history array
121
+ @exe = []
121
122
  # Paths
122
123
  @user = Etc.getpwuid(Process.euid).name # For use in @prompt
123
124
  @path = ENV["PATH"].split(":") # Get paths
@@ -434,16 +435,12 @@ def tab(type)
434
435
  hlp = hlp.reject{|h| /-</ =~ h}
435
436
  @tabarray = hlp
436
437
  when "all" # Handle all other tab completions
437
- exe = []
438
- @path.each do |p| # Add all executables in @path
439
- Dir.glob(p).each do |c|
440
- exe.append(File.basename(c)) if File.executable?(c) and not Dir.exist?(c)
441
- end
442
- end
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
438
+ ex = []
439
+ ex += @exe
440
+ ex.sort!
441
+ ex.prepend(*@nick.keys) # Add nicks
442
+ ex.prepend(*@gnick.keys) # Add gnicks
443
+ compl = ex.select {|s| s =~ Regexp.new(@tabstr)} # Select only that which matches so far
447
444
  fdir = @tabstr + "*"
448
445
  compl.prepend(*Dir.glob(fdir)).map! do |e|
449
446
  if e =~ /(?<!\\) /
@@ -548,19 +545,25 @@ def hist_clean # Clean up @history
548
545
  end
549
546
  def cmd_check(str) # Check if each element on the readline matches commands, nicks, paths; color them
550
547
  return if str.nil?
548
+ #elements = str.scan(/[^\s']+|'.+?'/)
549
+ #elements.map! do |el|
550
+ # .... the ifs
551
+ #elements.join(" ")
551
552
  str.gsub(/(?:\S'[^']*'|[^ '])+/) do |el|
552
- if @nick.include?(el)
553
+ if @exe.include?(el)
554
+ el.c(@c_cmd)
555
+ elsif el == "cd"
556
+ el.c(@c_cmd)
557
+ elsif File.executable?(el.gsub("'", ""))
558
+ el.c(@c_cmd)
559
+ elsif File.exist?(el.gsub("'", ""))
560
+ el.c(@c_path)
561
+ elsif @nick.include?(el)
553
562
  el.c(@c_nick)
554
563
  elsif el == "r" or el == "f"
555
564
  el.c(@c_nick)
556
565
  elsif @gnick.include?(el)
557
566
  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
567
  elsif el[0] == "-"
565
568
  el.c(@c_switch)
566
569
  else
@@ -669,6 +672,12 @@ loop do
669
672
  @prompt.gsub!(/#{Dir.home}/, '~') # Simplify path in prompt
670
673
  system("printf \"\033]0;rsh: #{Dir.pwd}\007\"") # Set Window title to path
671
674
  @history[0] = "" unless @history[0]
675
+ @exe = []
676
+ @path.each do |p| # Add all executables in @path
677
+ Dir.glob(p).each do |c|
678
+ @exe.append(File.basename(c)) if File.executable?(c) and not Dir.exist?(c)
679
+ end
680
+ end
672
681
  getstr # Main work is here
673
682
  @cmd = @history[0]
674
683
  @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.3'
4
+ version: '2.5'
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-24 00:00:00.000000000 Z
11
+ date: 2024-10-29 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.3: Better history search.'
16
+ other bug fixes. 2.5: Speedup of syntax highlighting and tab completions.'
17
17
  email: g@isene.com
18
18
  executables:
19
19
  - rsh