ruby-shell 0.15 → 0.17

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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -4
  3. data/bin/rsh +16 -5
  4. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0cc8a3f3e80656d09aeb3dc8e1d4a803d0cdd4230d2e32036d0de7fb24746b19
4
- data.tar.gz: b08319ac8b7c86c6ba235a45b03f84727e833477ea4aeb3f26a4422a19032632
3
+ metadata.gz: 6ea645b8bba423139ea6be4e7733105473c56e38d7a3906d45d4168b8acc2326
4
+ data.tar.gz: 5673ee1c0114d7f23526489c8110643190c49b1727b2558dd75d82bf41ad4442
5
5
  SHA512:
6
- metadata.gz: 5f9f896f49182e320519dce320605c8c9d1cdde7cbb072379062c148a8764f546673150bb8a7e18bf7fa8d841cffeb7f89966f9500b9c99cdc9b551778dfbba2
7
- data.tar.gz: 89fde9f621cf09e57dae9a2ce5f1182755769dc2d0ee53a91cec797ee0e1954b107f97d4cf9a879f0df13d27574d6fe19821632bc78de08137ee8f0efbbb9d7b
6
+ metadata.gz: 0ae62a4ab5e9723e317dd8b6146e849350fcd9083b0702a00ce2ea27ead76749c9fb41156931bc22386aa6c0fe06cf9d11ebd98c64f80852c331c1c3bccd39be
7
+ data.tar.gz: 5c053d2d1c193843c5b8112bc947541ae14169cb89a8a7b5153f1808394efea7a1eb223e2a28ff25352a6a39d6beccaa199a1eb054db71b11d791dc6e68a8fe1
data/README.md CHANGED
@@ -14,13 +14,16 @@ Clone this repo and drop `rsh` into your preferred bin directory. Drop `.rshrc`
14
14
 
15
15
  Or simply `gem install ruby-shell`.
16
16
 
17
+ # Screencast
18
+ [![rsh screencast](/img/rsh-screencast.png)](https://youtu.be/4P2z8oSo1u4)
19
+
17
20
  # Features
18
21
  * Aliases (called nicks in rsh) - both for commands and general nicks
19
22
  * Syntax highlighting, matching nicks, system commands and valid dirs/files
20
23
  * Tab completions for nicks, system commands, command switches and dirs/files
21
24
  * Tab completion presents matches in a list to pick from
22
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.
23
- * History with editing, search
26
+ * History with editing, search and repeat a history command (with `!`)
24
27
  * Config file (.rshrc) updates on exit (with Ctrl-d) or not (with Ctrl-c)
25
28
  * Set of simple rsh specific commands like nick, nick?, history and rmhistory
26
29
  * rsh specific commands and full set of Ruby commands available via :<command>
@@ -37,6 +40,7 @@ Special commands:
37
40
  * `:gnick 'h = /home/me'` to make a general alias (h) point to something (/home/me)
38
41
  * `:nick?` will list all command nicks and general nicks (you can edit your nicks in .rshrc)
39
42
  * `:history` will list the command history, while `:rmhistory` will delete the history
43
+ * `:version` Shows the rsh version number and the last published gem file version
40
44
  * `:help` will display this help text
41
45
 
42
46
  ## Moving around
@@ -50,6 +54,12 @@ You can tab complete almost anything. Hitting `TAB` will try to complete in this
50
54
 
51
55
  Hitting Shift-TAB will do a similar search through the command history - but with a general match of the search criteria (not only matching at the start).
52
56
 
57
+ ## Open files
58
+ 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`.
59
+
60
+ ## History
61
+ Show the history with `:history`. Redo a history command with an exclamation mark and the number corresponding to the position in the history, like `!5` would do the 5th history command again.
62
+
53
63
  ## Integrations
54
64
  rsh is integrated with the [rtfm file manager](https://github.com/isene/RTFM), with [fzf](https://github.com/junegunn/fzf) and with the programming language [XRPN](https://github.com/isene/xrpn).
55
65
 
@@ -76,9 +86,6 @@ Variable | Description
76
86
  `@c_taboption` | Color for unselected tabcompleted item
77
87
  `@c_stamp` | Color for time stamp/command
78
88
 
79
- # Open files
80
- 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`.
81
-
82
89
  # Enter the world of Ruby
83
90
  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.
84
91
 
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.15"
17
+ @version = "0.17"
18
18
 
19
19
  # MODULES, CLASSES AND EXTENSIONS
20
20
  class String # Add coloring to strings (with escaping for Readline)
@@ -146,7 +146,7 @@ end
146
146
  * Tab completion presents matches in a list to pick from
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
- * History with editing, search
149
+ * History with editing, search and repeat a history command (with `!`)
150
150
  * Config file (.rshrc) updates on exit (with Ctrl-d) or not (with Ctrl-c)
151
151
  * Set of simple rsh specific commands like nick, nick?, history and rmhistory
152
152
  * rsh specific commands and full set of Ruby commands available via :<command>
@@ -162,6 +162,7 @@ end
162
162
  * `:gnick 'h = /home/me'` to make a general alias (h) point to something (/home/me)
163
163
  * `:nick?` will list all command nicks and general nicks (you can edit your nicks in .rshrc)
164
164
  * `:history` will list the command history, while `:rmhistory` will delete the history
165
+ * `:version` Shows the rsh version number and the last published gem file version
165
166
  * `:help` will display this help text
166
167
 
167
168
  HELP
@@ -517,6 +518,8 @@ def cmd_check(str) # Check if each element on the readline matches commands, nic
517
518
  el.c(@c_path)
518
519
  elsif system "which #{el}", %i[out err] => File::NULL
519
520
  el.c(@c_cmd)
521
+ elsif el == "cd"
522
+ el.c(@c_cmd)
520
523
  elsif el =~ /^-/
521
524
  el.c(@c_switch)
522
525
  else
@@ -545,9 +548,12 @@ end
545
548
  def help
546
549
  puts @help
547
550
  end
551
+ def version
552
+ puts "rsh version = #{@version} (latest RubyGems version is #{Gem.latest_version_for("ruby-shell").version} - https://github.com/isene/rsh)"
553
+ end
548
554
  def history # Show history
549
555
  puts "History:"
550
- puts @history
556
+ @history.each_with_index {|h,i| puts i.to_s + "; " + h}
551
557
  end
552
558
  def rmhistory # Delete history
553
559
  @history = []
@@ -617,6 +623,10 @@ loop do
617
623
  @dirs.pop
618
624
  hist_clean # Clean up the history
619
625
  @cmd = "ls" if @cmd == "" # Default to ls when no command is given
626
+ if @cmd.match(/^!\d+/)
627
+ hi = @history[@cmd.sub(/^!(\d+)$/, '\1').to_i+1]
628
+ @cmd = hi if hi
629
+ end
620
630
  print "\n"; @c.clear_screen_down
621
631
  if @cmd == "r" # Integration with rtfm (https://github.com/isene/RTFM)
622
632
  t = Time.now
@@ -637,13 +647,14 @@ loop do
637
647
  rescue Exception => err
638
648
  puts "\n#{err}"
639
649
  end
640
- elsif @cmd == '#'
650
+ elsif @cmd == '#' # List previous directories
641
651
  dirs
642
652
  else # Execute command
643
653
  ca = @nick.transform_keys {|k| /((^\K\s*\K)|(\|\K\s*\K))\b(?<!-)#{Regexp.escape k}\b/}
644
654
  @cmd = @cmd.gsub(Regexp.union(ca.keys), @nick)
645
655
  ga = @gnick.transform_keys {|k| /\b#{Regexp.escape k}\b/}
646
656
  @cmd = @cmd.gsub(Regexp.union(ga.keys), @gnick)
657
+ @cmd = "~" if @cmd == "cd"
647
658
  @cmd.sub!(/^cd (\S*).*/, '\1')
648
659
  @cmd = Dir.home if @cmd == "~"
649
660
  @cmd = @dirs[1] if @cmd == "-"
@@ -655,7 +666,7 @@ loop do
655
666
  else
656
667
  puts "#{Time.now.strftime("%H:%M:%S")}: #{@cmd}".c(@c_stamp)
657
668
  if @cmd == "f" # fzf integration (https://github.com/junegunn/fzf)
658
- res = `#{@cmd}`.chomp
669
+ res = `fzf`.chomp
659
670
  Dir.chdir(File.dirname(res))
660
671
  else
661
672
  if File.exist?(@cmd)
metadata CHANGED
@@ -1,18 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-shell
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.15'
4
+ version: '0.17'
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-08 00:00:00.000000000 Z
11
+ date: 2023-06-09 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.15: Better stack handling for history.'
15
+ 0.17: Added the ! convention to redo history commands (like !5 to redo the 5th command
16
+ in hisotry)'
16
17
  email: g@isene.com
17
18
  executables:
18
19
  - rsh