ruby-shell 2.7.0 → 2.8.0
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 +11 -2
- data/bin/rsh +108 -34
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55c80db8b211f00c2226a2bc38de34ca8bc448ff38545043f24931bde8441de6
|
4
|
+
data.tar.gz: 7f70a5858de2c5d64800202a35af757b9bef6d864ccf76ab23dc673b82451fc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ad59802df4fc00d2d39191080b4a8df1d90ad5c567078c16562992b64d0aa8ad3ca59fdd9a0ab0bcefc35f6b02774305bec3f83872d463d27c2570887376901
|
7
|
+
data.tar.gz: 0a4cd352e6e20d25af578a689bffb6d460cc24f0b40328461b8a9ada40d3b03bda6e6c79674944170b752b7dc3787b9397869644025bc7925e90d54ce3bcff4e
|
data/README.md
CHANGED
@@ -33,7 +33,13 @@ Or simply `gem install ruby-shell`.
|
|
33
33
|
* All colors are themeable in .rshrc (see github link for possibilities)
|
34
34
|
* Copy current command line to primary selection (paste w/middle button) with `Ctrl-y`
|
35
35
|
|
36
|
-
## NEW in v2.
|
36
|
+
## NEW in v2.8.0 - Enhanced Help System & Nick Management ⭐
|
37
|
+
* **Two-column help display**: Compact, organized help that fits on one screen
|
38
|
+
* **New `:info` command**: Shows introduction and feature overview
|
39
|
+
* **`:nickdel` and `:gnickdel`**: Intuitive commands to delete nicks and gnicks
|
40
|
+
* **Improved help organization**: Quick reference for keyboard shortcuts, commands, and features
|
41
|
+
|
42
|
+
## Ruby Functions (v2.7.0)
|
37
43
|
* **Define Ruby functions as shell commands**: `:defun 'weather(*args) = system("curl -s wttr.in/#{args[0] || \"oslo\"}")'`
|
38
44
|
* **Call like any shell command**: `weather london`
|
39
45
|
* **Full Ruby power**: Access to Ruby stdlib, file operations, JSON parsing, web requests, etc.
|
@@ -58,13 +64,16 @@ Special functions/integrations:
|
|
58
64
|
Special commands:
|
59
65
|
* `:nick 'll = ls -l'` to make a command alias (ll) point to a command (ls -l)
|
60
66
|
* `:gnick 'h = /home/me'` to make a general alias (h) point to something (/home/me)
|
67
|
+
* `:nickdel 'name'` to delete a command nick (or use `:nick '-name'`)
|
68
|
+
* `:gnickdel 'name'` to delete a general nick (or use `:gnick '-name'`)
|
61
69
|
* `:nick?` will list all command nicks and general nicks (you can edit your nicks in .rshrc)
|
62
70
|
* `:history` will list the command history, while `:rmhistory` will delete the history
|
63
71
|
* `:jobs` will list background jobs, `:fg [job_id]` brings jobs to foreground, `:bg [job_id]` resumes stopped jobs
|
64
72
|
* `:defun 'func(args) = code'` defines Ruby functions callable as shell commands
|
65
73
|
* `:defun?` lists all user-defined functions, `:defun '-func'` removes functions
|
74
|
+
* `:info` shows introduction and feature overview
|
66
75
|
* `:version` Shows the rsh version number and the last published gem file version
|
67
|
-
* `:help` will display
|
76
|
+
* `:help` will display a compact command reference in two columns
|
68
77
|
|
69
78
|
Background jobs:
|
70
79
|
* Use `command &` to run commands in background
|
data/bin/rsh
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
# Web_site: http://isene.com/
|
9
9
|
# Github: https://github.com/isene/rsh
|
10
10
|
# License: Public domain
|
11
|
-
@version = "2.
|
11
|
+
@version = "2.8.0" # Feature release: nickdel functions, improved help system, info command
|
12
12
|
|
13
13
|
# MODULES, CLASSES AND EXTENSIONS
|
14
14
|
class String # Add coloring to strings (with escaping for Readline)
|
@@ -115,14 +115,15 @@ begin # Initialization
|
|
115
115
|
end
|
116
116
|
|
117
117
|
# HELP TEXT
|
118
|
-
@
|
118
|
+
@info = <<~INFO
|
119
119
|
|
120
120
|
Hello #{@user}, welcome to rsh - the Ruby SHell.
|
121
121
|
|
122
122
|
rsh does not attempt to compete with the grand old shells like bash and zsh.
|
123
123
|
It serves the specific needs and wants of its author. If you like it, then feel free
|
124
|
-
to ask for more or different features here: https://github.com/isene/rsh.
|
125
|
-
|
124
|
+
to ask for more or different features here: https://github.com/isene/rsh.
|
125
|
+
|
126
|
+
Features:
|
126
127
|
* Aliases (called nicks in rsh) - both for commands and general nicks
|
127
128
|
* Syntax highlighting, matching nicks, system commands and valid dirs/files
|
128
129
|
* Tab completions for nicks, system commands, command switches and dirs/files
|
@@ -137,41 +138,18 @@ end
|
|
137
138
|
* rsh specific commands and full set of Ruby commands available via :<command>
|
138
139
|
* All colors are themeable in .rshrc (see github link for possibilities)
|
139
140
|
* Copy current command line to primary selection (paste w/middle button) with `Ctrl-y`
|
140
|
-
|
141
|
-
Special functions/integrations:
|
142
|
-
* Use `r` to launch rtfm (https://github.com/isene/RTFM) - if you have it installed
|
143
|
-
* Use `f` to launch fzf (https://github.com/junegunn/fzf) - if you have it installed
|
144
|
-
* Use `=` followed by xrpn commands separated by commas or double-spaces (https://github.com/isene/xrpn)
|
145
|
-
* Use `:` followed by a Ruby expression to access the whole world of Ruby
|
146
|
-
|
147
|
-
Special commands:
|
148
|
-
* `:nick 'll = ls -l'` to make a command alias (ll) point to a command (ls -l)
|
149
|
-
* `:gnick 'h = /home/me'` to make a general alias (h) point to something (/home/me)
|
150
|
-
* `:nick?` will list all command nicks and general nicks (you can edit your nicks in .rshrc)
|
151
|
-
* `:history` will list the command history, while `:rmhistory` will delete the history
|
152
|
-
* `:jobs` will list background jobs, `:fg [job_id]` brings jobs to foreground, `:bg [job_id]` resumes stopped jobs
|
153
|
-
* `:defun 'func(args) = code'` defines Ruby functions callable as shell commands
|
154
|
-
* `:defun?` lists all user-defined functions, `:defun '-func'` removes functions
|
155
|
-
* `:version` Shows the rsh version number and the last published gem file version
|
156
|
-
* `:help` will display this help text
|
157
|
-
|
158
|
-
Background jobs:
|
159
|
-
* Use `command &` to run commands in background
|
160
|
-
* Use `:jobs` to list active background jobs
|
161
|
-
* Use `:fg` or `:fg job_id` to bring jobs to foreground
|
162
|
-
* Use `Ctrl-Z` to suspend running jobs, `:bg job_id` to resume them
|
163
141
|
|
164
|
-
|
165
|
-
* Define with `:defun 'myls(*args) = Dir.glob("*").each {|f| puts f}'`
|
166
|
-
* Call like any shell command: `myls` or `myls arg1 arg2`
|
167
|
-
* Functions have full access to Ruby stdlib and rsh internals
|
168
|
-
* Remove with `:defun '-myls'` and list with `:defun?`
|
142
|
+
Use `:help` for command reference.
|
169
143
|
|
144
|
+
INFO
|
145
|
+
|
146
|
+
@help = <<~HELP
|
147
|
+
|
170
148
|
HELP
|
171
149
|
|
172
150
|
# GENERIC FUNCTIONS
|
173
151
|
def firstrun
|
174
|
-
puts @
|
152
|
+
puts @info
|
175
153
|
puts "Since there is no rsh configuration file (.rshrc), I will help you set it up to suit your needs.\n\n"
|
176
154
|
puts "The prompt you see now is the very basic rsh prompt:"
|
177
155
|
print "#{@prompt} (press ENTER)"
|
@@ -610,7 +588,93 @@ end
|
|
610
588
|
|
611
589
|
# RSH FUNCTIONS
|
612
590
|
def help
|
613
|
-
|
591
|
+
# Get terminal width
|
592
|
+
term_width = @maxcol || 80
|
593
|
+
col_width = 48 # Fixed width for left column
|
594
|
+
|
595
|
+
# Helper function to strip ANSI codes for length calculation
|
596
|
+
def strip_ansi(str)
|
597
|
+
str.gsub(/\001?\e\[[0-9;]*m\002?/, '')
|
598
|
+
end
|
599
|
+
|
600
|
+
left_col = []
|
601
|
+
right_col = []
|
602
|
+
|
603
|
+
# Left column content
|
604
|
+
left_col << "KEYBOARD SHORTCUTS:".c(@c_prompt).b
|
605
|
+
left_col << "RIGHT/Ctrl-F Accept suggestion"
|
606
|
+
left_col << "UP/DOWN Navigate history"
|
607
|
+
left_col << "TAB Tab complete"
|
608
|
+
left_col << "Ctrl-Y Copy to clipboard"
|
609
|
+
left_col << "Ctrl-D Exit + save .rshrc"
|
610
|
+
left_col << "Ctrl-E Exit without save"
|
611
|
+
left_col << "Ctrl-L Clear screen"
|
612
|
+
left_col << "Ctrl-Z Suspend job"
|
613
|
+
left_col << "Ctrl-C/G Clear line"
|
614
|
+
left_col << "Ctrl-K Delete history item"
|
615
|
+
left_col << "Ctrl-U Clear line"
|
616
|
+
left_col << "Ctrl-W Delete previous word"
|
617
|
+
left_col << ""
|
618
|
+
left_col << "SPECIAL COMMANDS:".c(@c_prompt).b
|
619
|
+
left_col << ":nick 'll = ls -l' Command alias"
|
620
|
+
left_col << ":gnick 'h = /home' General alias"
|
621
|
+
left_col << ":nickdel 'name' Delete nick"
|
622
|
+
left_col << ":gnickdel 'name' Delete gnick"
|
623
|
+
left_col << ":nick? List all nicks"
|
624
|
+
left_col << ":history Show history"
|
625
|
+
left_col << ":rmhistory Clear history"
|
626
|
+
left_col << ":info About rsh"
|
627
|
+
left_col << ":version Version info"
|
628
|
+
left_col << ":help This help"
|
629
|
+
|
630
|
+
# Right column content
|
631
|
+
right_col << "RUBY FUNCTIONS:".c(@c_prompt).b
|
632
|
+
right_col << ":defun 'f(x) = x*2' Define function"
|
633
|
+
right_col << ":defun? List functions"
|
634
|
+
right_col << ":defun '-f' Remove function"
|
635
|
+
right_col << "Call as: f 5 (returns 10)"
|
636
|
+
right_col << ""
|
637
|
+
right_col << "JOB CONTROL:".c(@c_prompt).b
|
638
|
+
right_col << "command & Background job"
|
639
|
+
right_col << ":jobs List jobs"
|
640
|
+
right_col << ":fg [id] Foreground job"
|
641
|
+
right_col << ":bg [id] Resume in bg"
|
642
|
+
right_col << ""
|
643
|
+
right_col << "INTEGRATIONS:".c(@c_prompt).b
|
644
|
+
right_col << "r Launch rtfm"
|
645
|
+
right_col << "f Launch fzf"
|
646
|
+
right_col << "= <expr> xrpn calculator"
|
647
|
+
right_col << ":<ruby code> Execute Ruby"
|
648
|
+
right_col << ""
|
649
|
+
right_col << "EXPANSIONS:".c(@c_prompt).b
|
650
|
+
right_col << "~ Home directory"
|
651
|
+
right_col << "$VAR, ${VAR} Environment var"
|
652
|
+
right_col << "$? Exit status"
|
653
|
+
right_col << "$(cmd), `cmd` Command subst"
|
654
|
+
right_col << "{a,b,c} Brace expansion"
|
655
|
+
right_col << "cmd1 && cmd2 Conditional"
|
656
|
+
right_col << "cmd1 || cmd2 Alternative"
|
657
|
+
|
658
|
+
# Pad columns to same length
|
659
|
+
max_lines = [left_col.length, right_col.length].max
|
660
|
+
left_col.fill("", left_col.length...max_lines)
|
661
|
+
right_col.fill("", right_col.length...max_lines)
|
662
|
+
|
663
|
+
# Print in two columns
|
664
|
+
puts
|
665
|
+
max_lines.times do |i|
|
666
|
+
left_text = left_col[i].to_s
|
667
|
+
right_text = right_col[i].to_s
|
668
|
+
# Calculate padding based on visible characters (without ANSI codes)
|
669
|
+
visible_length = strip_ansi(left_text).length
|
670
|
+
padding = col_width - visible_length
|
671
|
+
padding = 0 if padding < 0
|
672
|
+
puts " #{left_text}#{' ' * padding} #{right_text}"
|
673
|
+
end
|
674
|
+
puts
|
675
|
+
end
|
676
|
+
def info
|
677
|
+
puts @info
|
614
678
|
end
|
615
679
|
def version
|
616
680
|
puts "rsh version = #{@version} (latest RubyGems version is #{Gem.latest_version_for("ruby-shell").version} - https://github.com/isene/rsh)"
|
@@ -651,6 +715,16 @@ def nick? # Show nicks
|
|
651
715
|
puts " General nicks:".c(@c_gnick)
|
652
716
|
@gnick.sort.each {|key, value| puts " #{key} = #{value}"}
|
653
717
|
end
|
718
|
+
def nickdel(nick_name) # Delete a command nick
|
719
|
+
@nick.delete(nick_name)
|
720
|
+
rshrc
|
721
|
+
puts "Nick '#{nick_name}' deleted"
|
722
|
+
end
|
723
|
+
def gnickdel(nick_name) # Delete a general/global nick
|
724
|
+
@gnick.delete(nick_name)
|
725
|
+
rshrc
|
726
|
+
puts "General nick '#{nick_name}' deleted"
|
727
|
+
end
|
654
728
|
def dirs
|
655
729
|
puts "Past direactories:"
|
656
730
|
@dirs.each_with_index do |e,i|
|
metadata
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-shell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geir Isene
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-07-
|
11
|
+
date: 2025-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'A shell written in Ruby with extensive tab completions, aliases/nicks,
|
14
|
-
history, syntax highlighting, theming, auto-cd, auto-opening files and more.
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
history, syntax highlighting, theming, auto-cd, auto-opening files and more. UPDATE
|
15
|
+
v2.8.0: Enhanced help system with two-column display, new :info command, :nickdel/:gnickdel
|
16
|
+
commands for easier nick management. v2.7.0: Ruby Functions - define custom shell
|
17
|
+
commands using full Ruby power! Also: job control, command substitution, variable
|
18
|
+
expansion, conditional execution, and login shell support.'
|
18
19
|
email: g@isene.com
|
19
20
|
executables:
|
20
21
|
- rsh
|