In the Bash shell, I would like to run a directory of ruby scripts from anywhere. Adding the directory to the $PATH doesn’t do it.
I want to type ‘ruby,’ start typing the first letters of a script name, and then press tab to autocomplete the script name.
For instance, I’m in /~/username/foo/bar and want to run /~/ruby/test/script1.rb
~/username/foo/bar $ ruby scri
press tab and
/username/foo/bar $ ruby script1.rb
appears. And then I’d be able to press enter and have the script run, even though I’m not in the right directory.
Is this possible?
If you add this to the top line of you scripts. Use ‘which ruby’ to find out where your interpreter is located and use that path instead.
Then change them to be executable with
You’ll be able to ruby them like any normal program, for example (although you may want to lose the .rb extension)