Rubish: A Bash-Compatible Unix Shell Built Entirely in Ruby
Rubish is a Unix shell written in pure Ruby that parses shell syntax, compiles it to Ruby code, and runs it on the Ruby VM. It aims for full bash compatibility — existing scripts should run unmodified — while layering Ruby semantics on top so users can mix shell pipelines with blocks, iterators, lambdas, and arbitrary Ruby expressions. Lines starting with a capital letter evaluate as Ruby, commands can be invoked with method-call syntax, and pipelines can chain into .select, .map, and other Ruby iterators that operate on command output line by line.
Beyond the language mashup, Rubish ships features aimed at daily use as a login shell: zsh-style prompt segments and abbreviated path expansion, lazy_load blocks that defer slow init scripts like rbenv and nvm to background threads for instant startup, and a -r flag that disables all Ruby integration for sandboxing untrusted scripts. A public Ruby API exposes the lexer, parser, completion, and prompt rendering so terminal emulators or IDE plugins can drive a rubish session in-process without fork/exec or JSON serialization — the companion Echoes terminal uses this for syntax-highlighted prompts.
The project is MIT-licensed and installable via Homebrew or from source. The safety-mode flag is worth noting for anyone considering it as a default shell: deep Ruby evaluation in interactive prompts is powerful but expands the attack surface for sourced rc files and pasted commands compared to a stock POSIX shell.
Read the full article
Continue reading at Hacker News →This is an AI-generated summary. Read the original for the full story.