+0
日增长
+0
周增长
300
stars
6
forks
5
watchers
43
prs
13
issues
0
releases
README
Rubish A UNIX shell written in pure Ruby. Shell syntax is parsed and compiled to Ruby code, then executed by the Ruby VM. Concept Fully Bash-compatible Rubish supports all the features of bash, and the shell syntax is fully compatible. You can run your existing bash scripts without modification. If you found any bash script that doesn't work in rubish, we consider it a bug, so please report it! Deep Ruby integration Rubish is not just a shell implemented in Ruby, but a shell that deeply integrates Ruby. You can seamlessly mix shell commands and Ruby code, and even use Ruby's powerful features like blocks, iterators, and libraries in your shell scripts. Installation Homebrew (macOS) sh brew tap amatsuda/rubish brew install --HEAD rubish From source sh git clone https://github.com/amatsuda/rubish.git cd rubish bundle install bundle exec exe/rubish bin/rubish is a small bash launcher that finds a usable Ruby on its own (probes ~/.rbenv/shims/ruby, /opt/homebrew/bin/ruby, /usr/local/bin/ruby, system Ruby; honors $ECHOES_RUBY, falling back to $RUBY for back-compat). Use it when bundler isn't around — for example as a login shell, from a .app bundle, or anywhere PATH may be minimal: sh ./bin/rubish ECHOES_RUBY=/opt/homebrew/opt/[email protected]/bin/ruby ./bin/rubish explicit override Usage Start an interactive shell: sh rubish Run a single command: sh rubish -c 'echo hello' Run a script: sh rubish script.sh Or you can even use this as a login shell! Set as login shell sh echo "$(which rubish)" | sudo tee -a /etc/shells chsh -s "$(which rubish)" Features beyond Bash Ruby conditions Use Ruby expressions as conditions in if, while, and until by wrapping them in { }. Shell variables are automatically bound as local variables in the Ruby expression: sh COUNT=5 if { count.to_i 3 } echo 'count is greater than 3' end while { count.to_i 0 } echo $COUNT COUNT=$((COUNT - 1)) done Ruby method call style Commands can be invoked using Ruby method call syntax with parentheses, in addition to the traditional UNIX style with spaces: sh These are equivalent: ls -la ls('-la') Arguments can be passed as method arguments: cat(file.txt) grep('pattern', file.txt) Method chaining Commands can be chained with Ruby methods using dot notation, forming a pipeline. The chain has to be opened by a parenthesized call, an array literal, or a block — once you're in chain context, subsequent methods can be bare: sh Equivalent to ls | sort ls().sort Equivalent to ls | sort | uniq ls().sort.uniq Equivalent to cat file.txt | grep error cat(file.txt).grep(/error/) Chains can be combined with blocks (see "Ruby iterator blocks" below) ls.select { it.end_with?('.rb') }.each { |f| puts f.upcase } The first segment needs the parens because bare cmd.method is ambiguous with paths and dotted filenames (./script.sh, file.tar.gz) — once () confirms a method-call form, the lexer knows it's safe to chain. Ruby iterator blocks
Top issues
#5I use rv as my Ruby Version manager - rubish fails5 comments · 2026-05-23#32The Rubish shell script Dir.glob crashes.1 comments · 2026-06-02#27Bash compatibility at about ~75%1 comments · 2026-05-27#12Improve Bash syntax1 comments · 2026-05-24#53`exit` doesn't work0 comments · 2026-06-23#30Y NO Gem?0 comments · 2026-05-29#13repl.send(:execute, line) leak issue.0 comments · 2026-05-24#10Feature request: Syntax highlighting0 comments · 2026-05-24