ruby-shell 0.10.1 → 0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -0
  3. data/bin/rsh +28 -12
  4. metadata +2 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2c7ebd4a7beebe30b2df0d2fcf14d1edc9f503730aaa1a3bf43253c83c844bec
4
- data.tar.gz: 602746338bda097043bf6bd465d39949cd1401660073b10f736bccf9d6b64aed
3
+ metadata.gz: 74027c13c7db62ce3aa12c55a297c1f5de6c1f90e65cd321b08233b21503f728
4
+ data.tar.gz: 640c81426e0f51d6dad3ae95a19b78ce66f47422c2375dc828b19434d03a18a3
5
5
  SHA512:
6
- metadata.gz: 50f8c28add6488b720bb28f669136c74c6f09681e4a8690293e1a9a5e7cb2ab13247d3e13c6cec090841c3f30229af9e87bfed322afec373920662b4a9477a91
7
- data.tar.gz: 89c72e7a3205a18c1d496dc1e2b058998b65b93fea587fc012b619365154d56d65d75d55b471d03b03e1f6c137431fbf760607407761897d22bfaca565f03faf
6
+ metadata.gz: 6aa949289f102093213e94cc4f984aa5bb5bde70979fe9ab2dee2b3aa9322b9c2123b1c3836f921c15d6917e4fcdd425b24648c18310a864878c01bc8c637218
7
+ data.tar.gz: 2f16565c9d92f4f281c4297f2177e0869449c02eed7f8eaa785295b5ed94bebecc0ed1339012b24f2d7bd45bcfd6e629db9d57e93f6581e4f88650697cb5d26f
data/README.md CHANGED
@@ -37,6 +37,7 @@ Special commands:
37
37
  * `:gnick 'h = /home/me'` to make a general alias (h) point to something (/home/me)
38
38
  * `:nick?` will list all command nicks and general nicks (you can edit your nicks in .rshrc)
39
39
  * `:history` will list the command history, while `:rmhistory` will delete the history
40
+ * `:help` will display this help text
40
41
 
41
42
  ## Nicks
42
43
  Add command nicks (aliases) with `:nick "some_nick = some_command"`, e.g. `:nick "ls = ls --color"`. Add general nicks that will substitute anything on a command line (not just commands) like this `:gnick "some_gnick = some_command"`, e.g. `:gnick "x = /home/user/somewhere"`. List (g)nicks with `:nick?`. Remove a nick with `:nick "-some_command"`, e.g. `:nick "-ls"` to remove an `ls` nick. Same for gnicks.
@@ -72,6 +73,9 @@ Variable | Description
72
73
  `@c_taboption` | Color for unselected tabcompleted item
73
74
  `@c_stamp` | Color for time stamp/command
74
75
 
76
+ # Open files
77
+ If you press `ENTER` after writing or tab-completing to a file, rsh will try to open the file in the user's EDITOR of choice (if it is a valid text file) or use `xdg-open` to open the file using the correct program. If you, for some reason want to use `run-mailcap` instead of `xdg-open` as the file opener, simply add `@runmailcap = true` to your `.rshrc`.
78
+
75
79
  # Enter the world of Ruby
76
80
  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.
77
81
 
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.10"
17
+ @version = "0.12"
18
18
 
19
19
  # MODULES, CLASSES AND EXTENSIONS
20
20
  class String # Add coloring to strings (with escaping for Readline)
@@ -125,13 +125,15 @@ begin # Initialization
125
125
  # History
126
126
  @histsize = 100 # Max history if not set in .rshrc
127
127
  @hloaded = false # Variable to determine if history is loaded
128
+ # Use run-mailcap instead of xgd-open? Set = true in .rshrc if iyou want run-mailcap
129
+ @runmailcap = false
128
130
  # Variable initializations
129
131
  @cmd = "" # Initiate variable @cmd
130
132
  end
131
133
 
132
- # GENERIC FUNCTIONS
133
- def firstrun
134
- @firstrun = <<~FIRSTRUN
134
+ # HELP TEXT
135
+ @help = <<~HELP
136
+
135
137
  Hello #{@user}, welcome to rsh - the Ruby SHell.
136
138
 
137
139
  rsh does not attempt to compete with the grand old shells like bash and zsh.
@@ -160,16 +162,19 @@ def firstrun
160
162
  * `:gnick 'h = /home/me'` to make a general alias (h) point to something (/home/me)
161
163
  * `:nick?` will list all command nicks and general nicks (you can edit your nicks in .rshrc)
162
164
  * `:history` will list the command history, while `:rmhistory` will delete the history
165
+ * `:help` will display this help text
163
166
 
164
- Since there is no rsh configuration file (.rshrc), I will help you set it up to suit your needs.
165
- FIRSTRUN
167
+ HELP
166
168
 
167
- puts @firstrun
168
- puts "The prompt you see now is the very basic rsh prompt: "
169
+ # GENERIC FUNCTIONS
170
+ def firstrun
171
+ puts @help
172
+ puts "Since there is no rsh configuration file (.rshrc), I will help you set it up to suit your needs.\n\n"
173
+ puts "The prompt you see now is the very basic rsh prompt:"
169
174
  print "#{@prompt} (press ENTER)"
170
175
  STDIN.gets
171
- puts "I will now change the prompt into something more useful."
172
- puts "Feel free to amend the prompt in your .rshrc."
176
+ puts "\nI will now change the prompt into something more useful."
177
+ puts "Feel free to amend the prompt in your .rshrc.\n\n"
173
178
  rc = <<~RSHRC
174
179
  # PROMPT
175
180
  # The numbers in parenthesis are 256 color codes (the '.c()' is a String extention
@@ -190,7 +195,6 @@ FIRSTRUN
190
195
  @nick = {"ls"=>"ls --color -F"}
191
196
  RSHRC
192
197
  File.write(Dir.home+'/.rshrc', rc)
193
-
194
198
  end
195
199
  def getchr # Process key presses
196
200
  c = STDIN.getch
@@ -509,6 +513,9 @@ def rshrc # Write updates to .rshrc
509
513
  end
510
514
 
511
515
  # RSH FUNCTIONS
516
+ def help
517
+ puts @help
518
+ end
512
519
  def history # Show history
513
520
  puts "History:"
514
521
  puts @history
@@ -606,7 +613,16 @@ loop do
606
613
  res = `#{@cmd}`.chomp
607
614
  Dir.chdir(File.dirname(res))
608
615
  else
609
- if File.exist?(@cmd) then system("#{ENV['EDITOR']} #{@cmd}") # Try open with user's editor
616
+ if File.exist?(@cmd)
617
+ if File.read(@cmd).force_encoding("UTF-8").valid_encoding?
618
+ system("#{ENV['EDITOR']} #{@cmd}") # Try open with user's editor
619
+ else
620
+ if @runmailcap
621
+ Thread.new { system("run-mailcap #{@cmd} 2>/dev/null") }
622
+ else
623
+ Thread.new { system("xdg-open #{@cmd} 2>/dev/null") }
624
+ end
625
+ end
610
626
  elsif system(@cmd) # Try execute the command
611
627
  else puts "No such command: #{@cmd}"
612
628
  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.10.1
4
+ version: '0.12'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
@@ -12,8 +12,7 @@ date: 2023-06-04 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.10: Added introduction and creation of .rshrc on first run. Improved rtfm integration.
16
- 0.10.1: Fixed depricated Dir.exists?'
15
+ 0.12: Added xdg-open (or run-mailcap) to open files.'
17
16
  email: g@isene.com
18
17
  executables:
19
18
  - rsh