ruby-shell 0.7 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rsh +23 -19
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 800a622da17daf070678be93473db6ebebbc8a2387230d1344941136914b43f5
4
- data.tar.gz: 3eb5c0b1067ed677d7215ac83e6d5ee2dc20075487bb3a090feb2614b5ab1220
3
+ metadata.gz: 947102ae716c38ff065cebc636d28aae8d41c558f498adc9b8a604c5bc3f63dc
4
+ data.tar.gz: f993423dc15b75bbace1628358f328b1a625f6b18d0afef80c2759b7f9b9a807
5
5
  SHA512:
6
- metadata.gz: f6a32929246f8af6064bec27ab4428c4bb82d850eb893d81ae00fe127390280b43e942cfb3d5e084d1e3bd9137f587d5c642b9a92df018aafa37f8d83805c063
7
- data.tar.gz: 4a8099fd7aa338d1f80845165b10cf7f225bf674951d3439feb719a6c7e2ccb520a45266e151357c3214f73b74951c8e6cc3fdfeff468ba32ed14b3ba16479eb
6
+ metadata.gz: 69a90e0445b80e42ca6c3f15da9ee4ca641e6465d09b3342c96d4abfec5179427261a2b4bc68709afc15f12ba3aeaa40790460daeff5dbeb8e0c42587572db8c
7
+ data.tar.gz: f7a5bba35ab0f40056e102dd7613761da1f3ce9d34f7043fa2ec616390a3626fab64aba52d7e55433abead4d9d74e1584073ada150d7bc7fd37de154449ebc07
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.6"
17
+ @version = "0.8"
18
18
 
19
19
  # MODULES, CLASSES AND EXTENSIONS
20
20
  class String # Add coloring to strings (with escaping for Readline)
@@ -423,7 +423,7 @@ def rshrc # Write updates to .rshrc
423
423
  conf.sub!(/^@history.*\n/, "")
424
424
  conf += "@history = #{@history.last(@histsize)}\n"
425
425
  File.write(Dir.home+'/.rshrc', conf)
426
- puts "\n .rshrc updated"
426
+ puts ".rshrc updated"
427
427
  end
428
428
 
429
429
  # RSH FUNCTIONS
@@ -480,24 +480,28 @@ end
480
480
 
481
481
  # MAIN PART
482
482
  loop do
483
- @user = Etc.getpwuid(Process.euid).name # For use in @prompt
484
- @node = Etc.uname[:nodename] # For use in @prompt
485
- h = @history; load(Dir.home+'/.rshrc') if File.exist?(Dir.home+'/.rshrc'); @history = h # reload prompt but not history
486
- @prompt.gsub!(/#{Dir.home}/, '~') # Simplify path in prompt
487
- @cmd = getstr # Main work is here
488
- hist_clean # Clean up the history
489
- @cmd = "ls" if @cmd == "" # Default to ls when no command is given
490
- print "\n"; @c.clear_screen_down
491
- if @cmd == "r" # Integration with rtfm (https://github.com/isene/RTFM)
492
- File.write("/tmp/.rshpwd", Dir.pwd)
493
- system("rtfm /tmp/.rshpwd")
494
- Dir.chdir(File.read("/tmp/.rshpwd"))
495
- next
496
- end
497
- @cmd = "echo \"#{@cmd[1...]},prx,off\" | xrpn" if @cmd =~ /^\=/ # Integration with xrpn (https://github.com/isene/xrpn)
498
483
  begin
484
+ @user = Etc.getpwuid(Process.euid).name # For use in @prompt
485
+ @node = Etc.uname[:nodename] # For use in @prompt
486
+ h = @history; load(Dir.home+'/.rshrc') if File.exist?(Dir.home+'/.rshrc'); @history = h # reload prompt but not history
487
+ @prompt.gsub!(/#{Dir.home}/, '~') # Simplify path in prompt
488
+ @cmd = getstr # Main work is here
489
+ hist_clean # Clean up the history
490
+ @cmd = "ls" if @cmd == "" # Default to ls when no command is given
491
+ print "\n"; @c.clear_screen_down
492
+ if @cmd == "r" # Integration with rtfm (https://github.com/isene/RTFM)
493
+ File.write("/tmp/.rshpwd", Dir.pwd)
494
+ system("rtfm /tmp/.rshpwd")
495
+ Dir.chdir(File.read("/tmp/.rshpwd"))
496
+ next
497
+ end
498
+ @cmd = "echo \"#{@cmd[1...]},prx,off\" | xrpn" if @cmd =~ /^\=/ # Integration with xrpn (https://github.com/isene/xrpn)
499
499
  if @cmd.match(/^\s*:/) # Ruby commands are prefixed with ":"
500
- eval(@cmd[1..-1])
500
+ begin
501
+ eval(@cmd[1..-1])
502
+ rescue Exception => err
503
+ puts "#{err}"
504
+ end
501
505
  else # Execute command
502
506
  @cmd.sub!(/^cd (\S*).*/, '\1')
503
507
  @cmd = Dir.home if @cmd == "~"
@@ -510,7 +514,7 @@ loop do
510
514
  ga = @gnick.transform_keys {|k| /\b#{Regexp.escape k}\b/}
511
515
  @cmd = @cmd.gsub(Regexp.union(ga.keys), @gnick)
512
516
  puts "#{Time.now.strftime("%H:%M:%S")}: #{@cmd}".c(@c_stamp)
513
- if @cmd == "fzf" # fzf integration (https://github.com/junegunn/fzf)
517
+ if @cmd == "f" # fzf integration (https://github.com/junegunn/fzf)
514
518
  res = `#{@cmd}`.chomp
515
519
  Dir.chdir(File.dirname(res))
516
520
  else
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-shell
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.7'
4
+ version: '0.8'
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-05-30 00:00:00.000000000 Z
11
+ date: 2023-06-01 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.7: Added XRPN integration :).'
15
+ 0.8: Better error handling.'
16
16
  email: g@isene.com
17
17
  executables:
18
18
  - rsh