ruby-shell 2.2 → 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 +29 -19
  3. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16401f8cae0a48a872039d91e89c0dfc441e1a6e06eba0c27d5035176daa6c24
4
- data.tar.gz: df7f01fe21f17b7e38578c5ef539532ea37f0af23f9c35b2cbcc214cfbe8624c
3
+ metadata.gz: e4cbdfe9d1c09e98287dff7de8cfabb7dd776fa6f7617f4a0801d17f7b463bad
4
+ data.tar.gz: cf3b1311d1891caa516b427ef065f79f3d6b23e2486f5d070111f7040a812a05
5
5
  SHA512:
6
- metadata.gz: 771ef428fc45880ca4bcfc954b4296a7d1cb98903b038a85aa8d959e2c1f0b5c7f568060b47adc7068020543fd1663a6473cfbf04ea636b7038e467115f89e13
7
- data.tar.gz: 69be18e3477784987d41b16b8376894a43d8efbe0e1313b36926342abece6769750a8965046f848bd138f5680d4a214cb9a1f08c93bbe99ad803f990030bbb94
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.2"
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
@@ -416,7 +417,8 @@ def tab(type)
416
417
  @postab = @history[0][@pos..].to_s # Extract the current line from cursor to end
417
418
  @c_row, @c_col = @c.pos # Get cursor position
418
419
  @tabstr = @pretab.split(/[|, ]/).last.to_s # Get the sustring that is being tab completed
419
- @tabstr = "" if @pretab[-1] =~ /[ |]/
420
+ @tabstr = "" if @pretab[-1] =~ /[ |]/ # Tab from nothing if tabbing starts with space or pipe
421
+ @tabstr = @pretab if type == "hist" # Searching for matches with whole string in history
420
422
  @pretab = @pretab.delete_suffix(@tabstr)
421
423
  type = "switch" if @tabstr[0] == "-"
422
424
  while chr != "ENTER"
@@ -433,16 +435,12 @@ def tab(type)
433
435
  hlp = hlp.reject{|h| /-</ =~ h}
434
436
  @tabarray = hlp
435
437
  when "all" # Handle all other tab completions
436
- exe = []
437
- @path.each do |p| # Add all executables in @path
438
- Dir.glob(p).each do |c|
439
- exe.append(File.basename(c)) if File.executable?(c) and not Dir.exist?(c)
440
- end
441
- end
442
- exe.sort!
443
- exe.prepend(*@nick.keys) # Add nicks
444
- exe.prepend(*@gnick.keys) # Add gnicks
445
- 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
446
444
  fdir = @tabstr + "*"
447
445
  compl.prepend(*Dir.glob(fdir)).map! do |e|
448
446
  if e =~ /(?<!\\) /
@@ -547,19 +545,25 @@ def hist_clean # Clean up @history
547
545
  end
548
546
  def cmd_check(str) # Check if each element on the readline matches commands, nicks, paths; color them
549
547
  return if str.nil?
548
+ #elements = str.scan(/[^\s']+|'.+?'/)
549
+ #elements.map! do |el|
550
+ # .... the ifs
551
+ #elements.join(" ")
550
552
  str.gsub(/(?:\S'[^']*'|[^ '])+/) do |el|
551
- 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)
552
562
  el.c(@c_nick)
553
563
  elsif el == "r" or el == "f"
554
564
  el.c(@c_nick)
555
565
  elsif @gnick.include?(el)
556
566
  el.c(@c_gnick)
557
- elsif File.exist?(el.gsub("'", ""))
558
- el.c(@c_path)
559
- elsif system "which #{el}", %i[out err] => File::NULL
560
- el.c(@c_cmd)
561
- elsif el == "cd"
562
- el.c(@c_cmd)
563
567
  elsif el[0] == "-"
564
568
  el.c(@c_switch)
565
569
  else
@@ -668,6 +672,12 @@ loop do
668
672
  @prompt.gsub!(/#{Dir.home}/, '~') # Simplify path in prompt
669
673
  system("printf \"\033]0;rsh: #{Dir.pwd}\007\"") # Set Window title to path
670
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
671
681
  getstr # Main work is here
672
682
  @cmd = @history[0]
673
683
  @dirs.unshift(Dir.pwd)
metadata CHANGED
@@ -1,20 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-shell
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.2'
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.1: Better error handling. 2.2: Fixed pasting to commandline and
17
- reading of PATH'
16
+ other bug fixes. 2.5: Speedup of syntax highlighting and tab completions.'
18
17
  email: g@isene.com
19
18
  executables:
20
19
  - rsh