How to I launch a ruby script from the command line by just its name?

后端 未结 3 1332
隐瞒了意图╮
隐瞒了意图╮ 2020-11-30 13:28

On windows, I can run my ruby script like this:

> ruby myscript.rb

but I want to set things up so that I can just do this instead?..

3条回答
  •  生来不讨喜
    2020-11-30 14:04

    Associate the ".rb" file extension with the ruby interpreter. On Windows XP, one way to do this is to select "Tools|Folder options" in the file explorer, and to setup the association in the "File types" tab.

    Another way would be to enter the following on the commandline which creates this file association for you:

    assoc .rb=RubyScript
    ftype RubyScript=ruby.exe %1 %*
    

提交回复
热议问题