I have a Ruby file, and I run it as ruby file.rb "parameters"
. I prefer to run it as regtask parameters
without having to include ruby
and the filename every time. I want it to be on the same level as ls
. How would I accomplish this?
Edit your file, make sure this is the first line, so your system knows how to execute your file:
#!/usr/bin/env ruby
Next, change the file's permissions to make it executable:
chmod a+x file.rb
And finally, rename it and move it somewhere where it will be executed without having to write its full path:
mkdir -p ~/bin
mv file.rb ~/bin/regtask
(Most systems will automatically add ~/bin
to PATH
if it exists; if not, you will have to add it to PATH
yourself in your startup files.)