Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ruby-shell

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ruby-shell

  • 2.6.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

rsh

Ruby Gem Version Unlicense Stay Amazing

The Ruby SHell

Why?

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.

Design principles

Simple. One file. Minimum external requirements.

Installation

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.

Screencast

rsh screencast

Features

  • Aliases (called nicks in rsh) - both for commands and general nicks
  • Syntax highlighting, matching nicks, system commands and valid dirs/files
  • Tab completions for nicks, system commands, command switches and dirs/files
  • Tab completion presents matches in a list to pick from
  • 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.
  • 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
  • History with editing, search and repeat a history command (with !)
  • Config file (.rshrc) updates on exit (with Ctrl-d) or not (with Ctrl-e)
  • Set of simple rsh specific commands like nick, nick?, history and rmhistory
  • rsh specific commands and full set of Ruby commands available via :
  • All colors are themeable in .rshrc (see github link for possibilities)
  • Copy current command line to primary selection (paste w/middle button) with Ctrl-y

Special functions/integrations:

Special 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)
  • :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
  • :version Shows the rsh version number and the last published gem file version
  • :help will display this help text

Moving around

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.

Nicks

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.

Tab completion

You can tab complete almost anything. Hitting TAB will try to complete in this priority: nicks, gnicks, commands, dirs/files. Hitting TABafter 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).

Open files

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.

History

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.

Integrations

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.

Syntax highlighting

rsh will highlight nicks, gnicks, commands and dirs/files as they are written on the command line.

Theming

In the supplied .rshrc, you will find a set of colors that you can change:

VariableDescription
@c_promptColor for basic prompt
@c_cmdColor for valid command
@c_nickColor for matching nick
@c_gnickColor for matching gnick
@c_pathColor for valid path
@c_tabselectColor for selected tabcompleted item
@c_taboptionColor for unselected tabcompleted item
@c_stampColor for time stamp/command

The .rshrc

.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.

Enter the world of Ruby

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.

Not yet implemented

Lots. Of. Stuff.

Forget it.

FAQs

Package last updated on 01 Nov 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc