quick starting a ruby script
Here's a quick way to create ruby scripts on your system without having to drop in your #!/path/to/ruby. As you can see, my ruby path is a bit convoluted, so this is quite helpful. This will also change your file to an executable so you can skip that step as well!
alias this script in your .alias or bashrc, our wherever else you keep your aliases and presto, easy and quick script kickstarter.
#!/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby
path = ARGV[0]
# if no script name is specified, fail out with error message
fail "Please specify a file path" unless path
#check if the file already exist and fail out if it does.
fail "file already exits" if File.exists?(path)
File.open(path, "w") { |f| f.puts "#!/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby -w" }
File.chmod(0755, path)
system "vim", path
Written by pansy
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#