ruby-shell 0.24 → 0.26

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 +2 -2
  3. data/bin/rsh +23 -18
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 206ad1334e7e4b4c43d32820d57946ae9a7cca94acd988bf4ebcdcc9aa4a72d7
4
- data.tar.gz: 17eb90fec5ca92c0995c2bac991af47147389a193b4ff41641fd72f4bc9647e2
3
+ metadata.gz: 748af44619d5fa3fe9949d80a0bbe6ee20b59f930d0aeb3a509fc87e75358b4c
4
+ data.tar.gz: abf4fdf08919b9703b839b9cf482b4d7c04f29018bf86c5656f162b04406760b
5
5
  SHA512:
6
- metadata.gz: 223b18a2c568229ef80bbbbe68c2807e8b747f7f435caba3123d6e250f0cd595bead703d5c3be9d10961d08179f200fbe73eefa40264c0e054a98e2da07e76aa
7
- data.tar.gz: 7ab4adf5d00f22ebe20f34702539d329fe82a0dc53d0ef7e558952287bebf6f6b28b0cd783673cedf4e86052cafc494d18969f5f4bc53b54dac1b8193112dc8d
6
+ metadata.gz: 87ba4d133d7e1d9db8fe8725b51ba07f23fccb91d64f8f77acc6b48e9577da746edfbc296c4776c95311ef1b11bc50223576f0579072a3c12099749b968e5568
7
+ data.tar.gz: 9390042b865bf9bc03d4ff9c569ca797e68763632dd940713d0826051600943640d563932b08946e757f99476b82f8b9157c44e3d923c6b408d63551e5e27aef
data/README.md CHANGED
@@ -23,9 +23,9 @@ Or simply `gem install ruby-shell`.
23
23
  * Tab completions for nicks, system commands, command switches and dirs/files
24
24
  * Tab completion presents matches in a list to pick from
25
25
  * When you start to write a command, rsh will suggest the first match in the history and present that in "toned down" letters - press the arrow right key to accept the suggestion.
26
- * Writing a partial command and pressing `UP` will search history for matches. Go down/up in the list and press `TAB` or `ENTER` to accept or `Ctrl-G` to discard
26
+ * Writing a partial command and pressing `UP` will search history for matches. Go down/up in the list and press `TAB` or `ENTER` to accept, `Ctrl-g` or `Ctrl-c` to discard
27
27
  * History with editing, search and repeat a history command (with `!`)
28
- * Config file (.rshrc) updates on exit (with Ctrl-d) or not (with Ctrl-c)
28
+ * Config file (.rshrc) updates on exit (with Ctrl-d) or not (with Ctrl-e)
29
29
  * Set of simple rsh specific commands like nick, nick?, history and rmhistory
30
30
  * rsh specific commands and full set of Ruby commands available via :<command>
31
31
  * All colors are themeable in .rshrc (see github link for possibilities)
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.24"
17
+ @version = "0.26"
18
18
 
19
19
  # MODULES, CLASSES AND EXTENSIONS
20
20
  class String # Add coloring to strings (with escaping for Readline)
@@ -147,9 +147,9 @@ end
147
147
  * When you start to write a command, rsh will suggest the first match in the history and
148
148
  present that in "toned down" letters - press the arrow right key to accept the suggestion
149
149
  * Writing a partial command and pressing `UP` will search history for matches.
150
- Go down/up in the list and press `TAB` or `ENTER` to accept or `Ctrl-G` to discard
151
- * History with editing, search and repeat a history command (with `!`)
152
- * Config file (.rshrc) updates on exit (with Ctrl-d) or not (with Ctrl-c)
150
+ Go down/up in the list and press `TAB` or `ENTER` to accept, `Ctrl-g` or `Ctrl-c` to discard
151
+ * History with editing, search and repeat a history command (with `!`)
152
+ * Config file (.rshrc) updates on exit (with Ctrl-d) or not (with Ctrl-e)
153
153
  * Set of simple rsh specific commands like nick, nick?, history and rmhistory
154
154
  * rsh specific commands and full set of Ruby commands available via :<command>
155
155
  * All colors are themeable in .rshrc (see github link for possibilities)
@@ -229,6 +229,7 @@ def getchr # Process key presses
229
229
  when "", "" then chr = "BACK"
230
230
  when "" then chr = "C-C"
231
231
  when "" then chr = "C-D"
232
+ when "" then chr = "C-E"
232
233
  when "" then chr = "C-G"
233
234
  when " " then chr = "C-K"
234
235
  when " " then chr = "C-L"
@@ -267,10 +268,10 @@ def getstr # A custom Readline-like function
267
268
  @c.col(@pos0 + @pos)
268
269
  chr = getchr
269
270
  case chr
270
- when 'C-G'
271
+ when 'C-G', 'C-C'
271
272
  @history[0] = ""
272
273
  return
273
- when 'C-C' # Ctrl-C exits gracefully but without updating .rshrc
274
+ when 'C-E' # Ctrl-C exits gracefully but without updating .rshrc
274
275
  print "\n"
275
276
  exit
276
277
  when 'C-D' # Ctrl-D exits after updating .rshrc
@@ -524,6 +525,8 @@ def cmd_check(str) # Check if each element on the readline matches commands, nic
524
525
  str.gsub(/\S+/) do |el|
525
526
  if @nick.include?(el)
526
527
  el.c(@c_nick)
528
+ elsif el == "r"
529
+ el.c(@c_nick)
527
530
  elsif @gnick.include?(el)
528
531
  el.c(@c_gnick)
529
532
  elsif File.exist?(el.sub(/^~/, "/home/#{@user}"))
@@ -608,7 +611,7 @@ end
608
611
 
609
612
  # INITIAL SETUP
610
613
  begin # Load .rshrc and populate @history
611
- trap "SIGINT" do print "\n"; exit end
614
+ trap "SIGINT" do end
612
615
  firstrun unless File.exist?(Dir.home+'/.rshrc') # Initial loading - to get history
613
616
  load(Dir.home+'/.rshrc')
614
617
  ENV["SHELL"] = __FILE__
@@ -690,19 +693,21 @@ loop do
690
693
  if @cmd == "f" # fzf integration (https://github.com/junegunn/fzf)
691
694
  res = `fzf`.chomp
692
695
  Dir.chdir(File.dirname(res))
693
- else
694
- if File.exist?(@cmd) and not File.executable?(@cmd)
695
- if File.read(@cmd).force_encoding("UTF-8").valid_encoding?
696
- system("#{ENV['EDITOR']} #{@cmd}") # Try open with user's editor
696
+ elsif File.exist?(@cmd) and not File.executable?(@cmd)
697
+ if File.read(@cmd).force_encoding("UTF-8").valid_encoding?
698
+ system("#{ENV['EDITOR']} #{@cmd}") # Try open with user's editor
699
+ else
700
+ if @runmailcap
701
+ Thread.new { system("run-mailcap #{@cmd} 2>/dev/null") }
697
702
  else
698
- if @runmailcap
699
- Thread.new { system("run-mailcap #{@cmd} 2>/dev/null") }
700
- else
701
- Thread.new { system("xdg-open #{@cmd} 2>/dev/null") }
702
- end
703
+ Thread.new { system("xdg-open #{@cmd} 2>/dev/null") }
703
704
  end
704
- elsif system(@cmd) # Try execute the command
705
- else puts "No such command or nick: #{@cmd}"
705
+ end
706
+ else
707
+ begin
708
+ puts "No such command or nick: #{@cmd}" unless system (@cmd) # Try execute the command
709
+ rescue StandardError => err
710
+ puts "\n#{err}"
706
711
  end
707
712
  end
708
713
  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.24'
4
+ version: '0.26'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
@@ -12,7 +12,7 @@ date: 2023-06-19 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.24: Minor bug fix in tab completion.'
15
+ 0.26: Finally fixed a graceful handling of Ctrl-c.'
16
16
  email: g@isene.com
17
17
  executables:
18
18
  - rsh