ruby-shell 0.16 → 0.19
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.
- checksums.yaml +4 -4
- data/README.md +20 -6
- data/bin/rsh +21 -6
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8c4db771e1dbd372496d80bf721a96c79e39ad21406e0cc2f68e3b382dd7df4
|
4
|
+
data.tar.gz: 7b7c8335bec3b659f7cc82f3f655dd179e053f74a016eed112969a2008cd0ced
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cfa55a0c59bfa616c725cee507632b85a2676a35cfc14f753bd673124d25bb74848a43ea6ac0cbdc09a8cf2c580f74ff93d0bb50602cfd8e760086365ec1705
|
7
|
+
data.tar.gz: 70f3584e3bfffe1b09f0bb3cc6bdf0b2aaa5028371d5b11ffae951bb2fd461babf4c989f682e22ccafea24fd9a1957ceaa7f6338b9443fa7baf44c6de46880f2
|
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
|
+
[](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,11 +40,9 @@ 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
|
-
## Screencast
|
43
|
-
[](https://youtu.be/4P2z8oSo1u4)
|
44
|
-
|
45
46
|
## Moving around
|
46
47
|
While you `cd` around to different directories, you can see the last 10 directories visited via the command `:dirs` or the convenient shortcut `#`. Entering the number in the list (like `6` and ENTER) will jump you to that directory. Entering `-` will jump you back to the previous dir (equivalent of `1`. Entering `~` will get you to your home dir. If you want to bookmark a special directory, you can do that via a general nick like this: `:gnick "x = /path/to/a/dir/"` - this would bookmark the directory to the single letter `x`.
|
47
48
|
|
@@ -53,6 +54,12 @@ You can tab complete almost anything. Hitting `TAB` will try to complete in this
|
|
53
54
|
|
54
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).
|
55
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
|
+
|
56
63
|
## Integrations
|
57
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).
|
58
65
|
|
@@ -79,8 +86,15 @@ Variable | Description
|
|
79
86
|
`@c_taboption` | Color for unselected tabcompleted item
|
80
87
|
`@c_stamp` | Color for time stamp/command
|
81
88
|
|
82
|
-
|
83
|
-
|
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
|
+
@editor = "vim"
|
93
|
+
@lscolors = "/home/geir/.local/share/lscolors.sh"
|
94
|
+
```
|
95
|
+
The `@editor` sets your editor of choice. The `@lscolors` points 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.
|
96
|
+
|
97
|
+
You can add any Ruby code to your .rshrc.
|
84
98
|
|
85
99
|
# Enter the world of Ruby
|
86
100
|
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.
|
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
|
+
@version = "0.19"
|
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
|
@@ -421,7 +422,7 @@ def tab_switch(str) # TAB completion for command switches (TAB after "-")
|
|
421
422
|
begin
|
422
423
|
hlp = `#{str} --help`
|
423
424
|
hlp = hlp.split("\n").grep(/^\s*-{1,2}[^-]/)
|
424
|
-
hlp = hlp.map
|
425
|
+
hlp = hlp.map{|h| h.sub(/^\s*/, '').sub(/^--/, ' --')}
|
425
426
|
switch = tabselect(hlp)
|
426
427
|
switch = switch.sub(/ .*/, '').sub(/,/, '')
|
427
428
|
@tabsearch = switch if switch
|
@@ -547,9 +548,12 @@ end
|
|
547
548
|
def help
|
548
549
|
puts @help
|
549
550
|
end
|
550
|
-
def
|
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
|
554
|
+
def history # Show most recent history (up to 50 entries)
|
551
555
|
puts "History:"
|
552
|
-
puts
|
556
|
+
@history.each_with_index {|h,i| puts i.to_s + "; " + h if i < 50}
|
553
557
|
end
|
554
558
|
def rmhistory # Delete history
|
555
559
|
@history = []
|
@@ -595,6 +599,13 @@ begin # Load .rshrc and populate @history
|
|
595
599
|
trap "SIGINT" do print "\n"; exit end
|
596
600
|
firstrun unless File.exist?(Dir.home+'/.rshrc') # Initial loading - to get history
|
597
601
|
load(Dir.home+'/.rshrc')
|
602
|
+
ENV["EDITOR"] = @editor
|
603
|
+
if File.exist?(@lscolors)
|
604
|
+
ls = File.read(@lscolors)
|
605
|
+
ls.sub!(/export.*/, '')
|
606
|
+
ls.sub!(/^LS_COLORS=/, 'ENV["LS_COLORS"]=')
|
607
|
+
eval(ls)
|
608
|
+
end
|
598
609
|
@c = Cursor # Initiate @c as Cursor
|
599
610
|
@c.save # Get max row & col
|
600
611
|
@c.row(8000)
|
@@ -619,6 +630,10 @@ loop do
|
|
619
630
|
@dirs.pop
|
620
631
|
hist_clean # Clean up the history
|
621
632
|
@cmd = "ls" if @cmd == "" # Default to ls when no command is given
|
633
|
+
if @cmd.match(/^!\d+/)
|
634
|
+
hi = @history[@cmd.sub(/^!(\d+)$/, '\1').to_i+1]
|
635
|
+
@cmd = hi if hi
|
636
|
+
end
|
622
637
|
print "\n"; @c.clear_screen_down
|
623
638
|
if @cmd == "r" # Integration with rtfm (https://github.com/isene/RTFM)
|
624
639
|
t = Time.now
|
@@ -639,7 +654,7 @@ loop do
|
|
639
654
|
rescue Exception => err
|
640
655
|
puts "\n#{err}"
|
641
656
|
end
|
642
|
-
elsif @cmd == '#'
|
657
|
+
elsif @cmd == '#' # List previous directories
|
643
658
|
dirs
|
644
659
|
else # Execute command
|
645
660
|
ca = @nick.transform_keys {|k| /((^\K\s*\K)|(\|\K\s*\K))\b(?<!-)#{Regexp.escape k}\b/}
|
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.
|
4
|
+
version: '0.19'
|
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-
|
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.
|
15
|
+
0.19: Added environment variables to .rshrc (@editor and @lscolors) and prettified
|
16
|
+
tab completions for command switches/options.'
|
16
17
|
email: g@isene.com
|
17
18
|
executables:
|
18
19
|
- rsh
|