ruby-shell 0.17 → 0.20

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 (5) hide show
  1. checksums.yaml +4 -4
  2. data/.rshrc +9 -4
  3. data/README.md +14 -0
  4. data/bin/rsh +15 -5
  5. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ea645b8bba423139ea6be4e7733105473c56e38d7a3906d45d4168b8acc2326
4
- data.tar.gz: 5673ee1c0114d7f23526489c8110643190c49b1727b2558dd75d82bf41ad4442
3
+ metadata.gz: b228176dfbc09b05c908d44bd1121aa7bd9c0c18c6cbf06c09a74bc9c4e492bb
4
+ data.tar.gz: 8ff9a56792681fcc704ec6de601255a43c4b5e23a88b100f121d5e2c33c9aa7a
5
5
  SHA512:
6
- metadata.gz: 0ae62a4ab5e9723e317dd8b6146e849350fcd9083b0702a00ce2ea27ead76749c9fb41156931bc22386aa6c0fe06cf9d11ebd98c64f80852c331c1c3bccd39be
7
- data.tar.gz: 5c053d2d1c193843c5b8112bc947541ae14169cb89a8a7b5153f1808394efea7a1eb223e2a28ff25352a6a39d6beccaa199a1eb054db71b11d791dc6e68a8fe1
6
+ metadata.gz: 6c6b7100c0eda1aa62a1f74839d5c6bbaa80f99f788ed106f3f98c7b0e7ee8ee705dcfe69cb692ebd0f275e264324cec53bc2874e4e638b705c6b9a49277a6fc
7
+ data.tar.gz: 9d01e0a80972585cef90ed9e90f865f13aebb03e04502084a4a9f65500430ca548e19b3a5eb8c9dbfd594bcefe836bb33aea110f7ace4e20b6253ca270621fff
data/.rshrc CHANGED
@@ -1,10 +1,13 @@
1
1
  # vim: set ft=ruby sw=2 sts=2 et :
2
2
 
3
+ # ENVIRONMENT
4
+ #@lscolors = "/home/geir/.local/share/lscolors.sh"
5
+ ENV["EDITOR"] = "vim"
6
+ ENV["MANPAGER"] = "vim +MANPAGER -"
7
+
3
8
  # PROMPT
4
- # The numbers in parenthesis are 256 color codes (the '.c()' is a String extention
5
- # to color text in the terminal. Add '.b' for bold and '.i' for italics.
6
9
  if @user == "root"
7
- @prompt = "#{@user}@#{@node}".c(160) + ":".c(255) + " #{Dir.pwd}/".c(196) + " ".c(7)
10
+ @prompt = "#{@user}@#{@node}".c(160).b + ":".c(255) + " #{Dir.pwd}/".c(196) + " ".c(7)
8
11
  else
9
12
  @prompt = "#{@user}@#{@node}".c(46) + ":".c(255) + " #{Dir.pwd}/".c(196) + " ".c(7)
10
13
  end
@@ -20,5 +23,7 @@ end
20
23
  @c_taboption = 244 # Color for unselected tabcompleted item
21
24
  @c_stamp = 244 # Color for time stamp/command
22
25
 
23
- # UPDATED ON CTRL-D EXIT
26
+ # NICKS AND HISTORY
24
27
  @nick = {"ls"=>"ls --color -F"}
28
+ @gnick = {}
29
+ @history = []
data/README.md CHANGED
@@ -86,6 +86,20 @@ Variable | Description
86
86
  `@c_taboption` | Color for unselected tabcompleted item
87
87
  `@c_stamp` | Color for time stamp/command
88
88
 
89
+ ## The .rshrc
90
+ `.rshrc` is the configuration file for rsh and it is located in your home directory. It is created when you first start rsh and you can modify it to suit your needs. A more detailed .rshrc is found in the the [rsh github repo](https://github.com/isene/rsh) - you can drop this into your home dir if you like. Set the basic environment variables like this:
91
+ ```
92
+ ENV["EDITOR"] = "vim"
93
+ ENV["MANPAGER"] = "vim +MANPAGER -"
94
+ ```
95
+ Also, a special variable for better LS_COLOR setup:
96
+ ```
97
+ @lscolors = "/home/geir/.local/share/lscolors.sh"
98
+ ```
99
+ Point `@lscolors` to a file that sets your LS_COLORS variable. Use [my extended LS_COLORS setup](https://github.com/isene/LS_COLORS) to make this really fancy.
100
+
101
+ You can add any Ruby code to your .rshrc.
102
+
89
103
  # Enter the world of Ruby
90
104
  By entering `:some-ruby-command` you have full access to the Ruby universe right from your command line. You can do anything from `:puts 2 + 13` or `:if 0.7 > Math::sin(34) then puts "OK" end` or whatever tickles you fancy.
91
105
 
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"
17
+ @version = "0.20"
18
18
 
19
19
  # MODULES, CLASSES AND EXTENSIONS
20
20
  class String # Add coloring to strings (with escaping for Readline)
@@ -422,7 +422,7 @@ def tab_switch(str) # TAB completion for command switches (TAB after "-")
422
422
  begin
423
423
  hlp = `#{str} --help`
424
424
  hlp = hlp.split("\n").grep(/^\s*-{1,2}[^-]/)
425
- hlp = hlp.map {|h| h.sub(/^\s*/, '')}
425
+ hlp = hlp.map{|h| h.sub(/^\s*/, '').sub(/^--/, ' --')}
426
426
  switch = tabselect(hlp)
427
427
  switch = switch.sub(/ .*/, '').sub(/,/, '')
428
428
  @tabsearch = switch if switch
@@ -551,9 +551,9 @@ end
551
551
  def version
552
552
  puts "rsh version = #{@version} (latest RubyGems version is #{Gem.latest_version_for("ruby-shell").version} - https://github.com/isene/rsh)"
553
553
  end
554
- def history # Show history
554
+ def history # Show most recent history (up to 50 entries)
555
555
  puts "History:"
556
- @history.each_with_index {|h,i| puts i.to_s + "; " + h}
556
+ @history.each_with_index {|h,i| puts i.to_s + "; " + h if i < 50}
557
557
  end
558
558
  def rmhistory # Delete history
559
559
  @history = []
@@ -599,6 +599,16 @@ begin # Load .rshrc and populate @history
599
599
  trap "SIGINT" do print "\n"; exit end
600
600
  firstrun unless File.exist?(Dir.home+'/.rshrc') # Initial loading - to get history
601
601
  load(Dir.home+'/.rshrc')
602
+ ENV["SHELL"] = __FILE__
603
+ ENV["TERM"] = "rxvt-unicode-256color"
604
+ ENV["PATH"] ? ENV["PATH"] += ":" : ENV["PATH"] = ""
605
+ ENV["PATH"] += "/home/#{@user}/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
606
+ if File.exist?(@lscolors)
607
+ ls = File.read(@lscolors)
608
+ ls.sub!(/export.*/, '')
609
+ ls.sub!(/^LS_COLORS=/, 'ENV["LS_COLORS"]=')
610
+ eval(ls)
611
+ end
602
612
  @c = Cursor # Initiate @c as Cursor
603
613
  @c.save # Get max row & col
604
614
  @c.row(8000)
@@ -669,7 +679,7 @@ loop do
669
679
  res = `fzf`.chomp
670
680
  Dir.chdir(File.dirname(res))
671
681
  else
672
- if File.exist?(@cmd)
682
+ if File.exist?(@cmd) and not File.executable?(@cmd)
673
683
  if File.read(@cmd).force_encoding("UTF-8").valid_encoding?
674
684
  system("#{ENV['EDITOR']} #{@cmd}") # Try open with user's editor
675
685
  else
metadata CHANGED
@@ -1,19 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-shell
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.17'
4
+ version: '0.20'
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-06-09 00:00:00.000000000 Z
11
+ date: 2023-06-12 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.17: Added the ! convention to redo history commands (like !5 to redo the 5th command
16
- in hisotry)'
15
+ 0.20: Changes needed to make rsh a proper login shell.'
17
16
  email: g@isene.com
18
17
  executables:
19
18
  - rsh