
Security News
CISA’s 2025 SBOM Guidance Adds Hashes, Licenses, Tool Metadata, and Context
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
The Ruby SHell
Ruby is my goto language (pun kinda intended). I want full control over my tools and I like challenges that I can tinker with late at night. This is an incomplete project continually being improved. Feel free to add suggestions or code.
Simple. One file. Minimum external requirements.
Clone this repo and drop rsh
into your preferred bin directory. Drop .rshrc
into your home directory and edit as you see fit.
Or simply gem install ruby-shell
.
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!
)Ctrl-y
@ <question>
: Ask questions and get AI-generated text responses@@ <request>
: Describe what you want to do, and AI suggests the command.rshrc
:info
command: Shows introduction and feature overview:nickdel
and :gnickdel
: Intuitive commands to delete nicks and gnicks:defun 'weather(*args) = system("curl -s wttr.in/#{args[0] || \"oslo\"}")'
weather london
:defun?
to list, :defun '-name'
to removecommand &
), job suspension (Ctrl-Z
), process management:jobs
, :fg [id]
, :bg [id]
commands$(date)
and backtick support$HOME
, $USER
, $?
(exit status)cmd1 && cmd2 || cmd3
{a,b,c}
expands to a b c
Special functions/integrations:
r
to launch rtfm (https://github.com/isene/RTFM) - if you have it installedf
to launch fzf (https://github.com/junegunn/fzf) - if you have it installed=
followed by xrpn commands separated by commas (https://github.com/isene/xrpn):
followed by a Ruby expression to access the whole world of RubySpecial commands:
:nick 'll = ls -l'
to make a command alias (ll) point to a command (ls -l):gnick 'h = /home/me'
to make a general alias (h) point to something (/home/me):nickdel 'name'
to delete a command nick (or use :nick '-name'
):gnickdel 'name'
to delete a general nick (or use :gnick '-name'
):nick?
will list all command nicks and general nicks (you can edit your nicks in .rshrc):history
will list the command history, while :rmhistory
will delete the history:jobs
will list background jobs, :fg [job_id]
brings jobs to foreground, :bg [job_id]
resumes stopped jobs:defun 'func(args) = code'
defines Ruby functions callable as shell commands:defun?
lists all user-defined functions, :defun '-func'
removes functions:info
shows introduction and feature overview:version
Shows the rsh version number and the last published gem file version:help
will display a compact command reference in two columnsBackground jobs:
command &
to run commands in background:jobs
to list active background jobs:fg
or :fg job_id
to bring jobs to foregroundCtrl-Z
to suspend running jobs, :bg job_id
to resume themThe AI features work out of the box with Ollama for local AI processing. To set up:
curl -fsSL https://ollama.com/install.sh | sh
ollama pull llama3.2
@ What is the capital of France?
or @@ list files by size
Add to your .rshrc
:
@aimodel = "gpt-4"
@aikey = "your-api-key-here"
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
.
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.
You can tab complete almost anything. Hitting TAB
will try to complete in this priority: nicks, gnicks, commands, dirs/files. Hitting TAB
after a -
will list the command switches for the preceding command with a short explanation (from the command's --help), like this ls -
(TAB
) will list all the switches/options for the ls
command. You can add to (or subtract from) the search criteria while selecting possible matches - hit any letter to specify the search, while backspace removes a letter from the search criteria.
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).
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
.
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. To delete a specific entry in history, hit UP
and move up to that entry and hit Ctrl-k
(for "kill").
rsh's unique Ruby functions let you define custom shell commands using the full power of Ruby:
# File operations
:defun 'count(*args) = puts Dir.glob(args[0] || "*").length'
count *.rb
# System monitoring
:defun 'mem = puts `free -h`.lines[1].split[2]'
mem
# JSON pretty-printing
:defun 'jsonpp(file) = require "json"; puts JSON.pretty_generate(JSON.parse(File.read(file)))'
jsonpp config.json
# Network tools
:defun 'ports = puts `netstat -tlnp`.lines.grep(/LISTEN/).map{|l| l.split[3]}'
ports
# Git helpers
:defun 'branches = puts `git branch`.lines.map{|l| l.strip.sub("* ", "")}'
branches
# Directory analysis
:defun 'sizes(*args) = Dir.glob(args[0] || "*").each{|f| puts "#{File.size(f).to_s.rjust(8)} #{f}" if File.file?(f)}'
sizes
# Weather (using external API)
:defun 'weather(*args) = system("curl -s wttr.in/#{args[0] || \"oslo\"}")'
weather london
:defun? # List all defined functions
:defun '-myls' # Remove a function
Ruby functions have access to:
ENV
@history
, @dirs
rsh is integrated with the rtfm file manager, with fzf and with the programming language XRPN.
Just enter the command r
and rtfm will be launched - and when you quit the file manager, you will drop back into rsh in the directory you where you exited rtfm.
Enter the command f
to launch the fuzzy finder - select the directory/file you want, press ENTER
and you will find yourself in the directory where that item resides.
If you start a line with "=", the rest of the line will be interpreted as an XRPN program. This gives you the full power of XRPN right at your fingertips. You can do simple stuff like this: =13,23,*,x^2
and the answer to (13 * 23)^2
will be given (89401) in the format that you have set in your .xrpn/conf
. Or you can do more elaborate stuff like =fix 6,5,sto c,time,'Time now is: ',atime,aview,pse,fix 0,lbl a,rcl c,prx,dse c,gto a
. Go crazy. Use single-quotes for any Alpha entry.
rsh will highlight nicks, gnicks, commands and dirs/files as they are written on the command line.
In the supplied .rshrc
, you will find a set of colors that you can change:
Variable | Description |
---|---|
@c_prompt | Color for basic prompt |
@c_cmd | Color for valid command |
@c_nick | Color for matching nick |
@c_gnick | Color for matching gnick |
@c_path | Color for valid path |
@c_tabselect | Color for selected tabcompleted item |
@c_taboption | Color for unselected tabcompleted item |
@c_stamp | Color for time stamp/command |
.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 - you can drop this into your home dir if you like. Set the basic environment variables like this:
ENV["EDITOR"] = "vim"
ENV["MANPAGER"] = "vim +MANPAGER -"
Also, a special variable for better LS_COLOR setup:
@lscolors = "/home/geir/.local/share/lscolors.sh"
Point @lscolors
to a file that sets your LS_COLORS variable. Use my extended LS_COLORS setup to make this really fancy.
You can add any Ruby code to your .rshrc.
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.
Lots. Of. Stuff.
Forget it.
FAQs
Unknown package
We found that ruby-shell demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.