Rubish: A Unix shell written in pure Ruby
Recorded: May 23, 2026, 9:58 a.m.
| Original | Summarized |
GitHub - amatsuda/rubish · GitHub Skip to content Navigation Menu Toggle navigation
Sign in
Appearance settings PlatformAI CODE CREATIONGitHub CopilotWrite better code with AIGitHub SparkBuild and deploy intelligent appsGitHub ModelsManage and compare promptsMCP RegistryNewIntegrate external toolsDEVELOPER WORKFLOWSActionsAutomate any workflowCodespacesInstant dev environmentsIssuesPlan and track workCode ReviewManage code changesAPPLICATION SECURITYGitHub Advanced SecurityFind and fix vulnerabilitiesCode securitySecure your code as you buildSecret protectionStop leaks before they startEXPLOREWhy GitHubDocumentationBlogChangelogMarketplaceView all featuresSolutionsBY COMPANY SIZEEnterprisesSmall and medium teamsStartupsNonprofitsBY USE CASEApp ModernizationDevSecOpsDevOpsCI/CDView all use casesBY INDUSTRYHealthcareFinancial servicesManufacturingGovernmentView all industriesView all solutionsResourcesEXPLORE BY TOPICAISoftware DevelopmentDevOpsSecurityView all topicsEXPLORE BY TYPECustomer storiesEvents & webinarsEbooks & reportsBusiness insightsGitHub SkillsSUPPORT & SERVICESDocumentationCustomer supportCommunity forumTrust centerPartnersView all resourcesOpen SourceCOMMUNITYGitHub SponsorsFund open source developersPROGRAMSSecurity LabMaintainer CommunityAcceleratorGitHub StarsArchive ProgramREPOSITORIESTopicsTrendingCollectionsEnterpriseENTERPRISE SOLUTIONSEnterprise platformAI-powered developer platformAVAILABLE ADD-ONSGitHub Advanced SecurityEnterprise-grade security featuresCopilot for BusinessEnterprise-grade AI featuresPremium SupportEnterprise-grade 24/7 supportPricing Search or jump to... Search code, repositories, users, issues, pull requests...
Search Clear
Search syntax tips Provide feedback Include my email address so I can be contacted Cancel Submit feedback Saved searches
Name Query To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up
Appearance settings Resetting focus You signed in with another tab or window. Reload to refresh your session. Dismiss alert amatsuda rubish Public
Notifications
Fork
Star Code Issues Pull requests Actions Projects Security and quality Insights
Additional navigation options
Code Issues Pull requests Actions Projects Security and quality Insights
masterBranchesTagsGo to fileCodeOpen more actions menuFolders and filesNameNameLast commit messageLast commit dateLatest commit History544 Commits544 Commits.github/workflows.github/workflows binbin exeexe liblib sigsig testtest .dockerignore.dockerignore .gitignore.gitignore DockerfileDockerfile GemfileGemfile LICENSE.txtLICENSE.txt README.mdREADME.md RakefileRakefile rubish-gem.gemspecrubish-gem.gemspec View all filesRepository files navigationREADMEMIT licenseRubish From source while { count.to_i > 0 } # Arguments can be passed as method arguments: # Equivalent to `ls | sort | uniq` # Equivalent to `cat file.txt | grep error` # Chains can be combined with blocks (see "Ruby iterator blocks" below) rubish$ Dir.glob('*.rb').sort rubish$ ENV['HOME'] Ruby array and regexp literals Lambda expressions Ruby-style function definitions def log(level, *messages) greet world # => Hello, world def rubish_right_prompt lazy_load { setopt/unsetopt Configuration files /etc/profile Interactive shells load: ~/.config/rubish/config or ~/.rubishrc (or ~/.bashrc) Logout: ~/.config/rubish/logout or ~/.rubish_logout (or ~/.bash_logout) Embedding in a Ruby program repl = Rubish::REPL.new(login_shell: true) # Run interactively (default). # Or drive it programmatically. Rubish::REPL.new(frontend: MyFrontend.new).run Category Directory I/O Variables Process Job control Functions Aliases History Execution Testing Control Completion Config Info Other Development About No description, website, or topics provided. Readme MIT license Uh oh! There was an error while loading. Please reload this page. Activity 81 1 2 Report repository Releases 1 Packages
Uh oh! There was an error while loading. Please reload this page. Contributors Uh oh! There was an error while loading. Please reload this page. Languages Ruby Other
Footer © 2026 GitHub, Inc. Footer navigation Terms Privacy Security Status Community Docs Contact Manage cookies Do not share my personal information You can’t perform that action at this time. |
Rubish is presented as a UNIX shell implemented in pure Ruby, distinguished by its deep integration of Ruby programming concepts with traditional shell functionality. The core design ensures that Rubish maintains full compatibility with Bash, allowing users to execute existing Bash scripts without modification. This compatibility is achieved by parsing and compiling shell syntax into executable Ruby code, which is then run by the Ruby Virtual Machine. The primary distinction of Rubish lies in its ability to seamlessly mix shell commands with powerful Ruby features such as blocks, iterators, and libraries directly within shell scripts and interactive sessions. Installation methods include using Homebrew on macOS, which provides commands to tap the repository and install the package, or cloning the source code from the repository and running bundle install. The executable, bin/rubish, functions as a small Bash launcher designed to locate a suitable Ruby installation, respecting the $RUBY environment variable. Users can interact with the shell in several ways, including starting an interactive session, executing a single command, or running a script, and it can also be configured as a login shell. Beyond basic command execution, Rubish incorporates advanced Ruby features directly into shell scripting. For conditional logic, Ruby expressions can be used within if, while, and until statements, where shell variables are automatically bound as local variables within these expressions. Furthermore, command invocation supports Ruby method call syntax, allowing commands to be invoked using parentheses, such as ls('-la'), and arguments can be passed as method arguments, such as cat(file.txt). This capability extends to establishing pipelines through method chaining using dot notation, provided the chain is initiated by a parenthesized call, an array literal, or a block, which serves to disambiguate method calls versus file paths. The system supports complex data processing via Ruby iterator blocks, such as .each, .map, and .select, which can be applied to command output line by line, enabling sophisticated filtering and transformation. Inline Ruby evaluation allows any line starting with a capital letter to be executed as Ruby code directly from the shell prompt, enabling dynamic computations using Ruby classes and methods. The system also supports Ruby array and regular expression literals, and the use of lambda expressions for defining executable blocks. The shell also supports defining custom functions using Ruby-style def...end syntax, including named parameters and splat arguments. The architecture allows for highly customizable user experiences through the definition of custom Ruby prompts, which can dynamically incorporate information gathered from the environment or Git status at the prompt rendering time. Performance optimization is addressed through lazy loading, a mechanism that defers the execution of slow shell initializations, such as those related to environment setup, to a background thread, ensuring instant shell startup. The system also offers a restricted mode, executed via rubish -r, which disables all advanced Ruby integrations, confining execution strictly to standard shell syntax for enhanced security when handling untrusted scripts. Compatibility extends to Zsh features and prompt codes, in addition to full Bash support. The integration extends into the programmatic layer via a public API, allowing other Ruby programs to interact with a Rubish session in-process without relying on separate processes or serialization. This API enables functionalities such as tokenizing command input, parsing Abstract Syntax Trees (ASTs), performing completion suggestions, and managing prompt segments with color and styling. Furthermore, the system offers options for custom I/O backends to integrate with external front-end processes. Built-in commands cover essential system operations including directory manipulation, input/output functions, variable management, process control, history management, and execution control. |