I'm used to executing python in the Terminal to get to an interactive Python session where I can try things before using them in a script. In Ruby, however, executing ruby doesn't work like that (the REPL is called irb).
How can I make it so that calling ruby without arguments executes irb and ruby ex1.rb, ruby --help, etc. still work?
1 Answer
I came up with this surprisingly simple Python script (hah):
import sys, os
if len(sys.argv) == 1: os.system('irb')
else: os.system('ruby ' + sys.argv[1])I saved this as ruby.py in my home directory and added it to my .zshrc as follows:
alias ruby="python ~/ruby.py"and it's working.
I'm wondering if this is the best or a bug-free solution, though. (For instance with other scripts)