s/run/the-correct-program/ $@
Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
examples
.gitignore
README
setup.sh

README

run

s/run/the-correct-program/ $@

run dispatches command line arguments to a program, based on the files #!, then based your configuration in your .runrc file(s).
I find this useful for running a number of different types of scripts with the same command in my IDE/Text editor.

For example, I program in Ruby and Node.js. I want to use the same command to run my scripts, despite having to switch between two languages.
All I need to do now is run:

    run my_spec.rb

In my .runrc file, I have a mapping between files with the extension .rb and ruby.

Here is my ~/.runrc file.

    #!/bin/bash
    file=$1
    if [[ $file =~  .rb$ ]]; then exec ruby $@; fi
    if [[ $file =~  .js$ ]]; then exec node $@; fi

run also allows you to configure a separate .runrc file in a directory-specific basis.
For example, I'm working on my fork (http://github.com/btakita/jasmine-node) of the jasmine-node project. 
In order to run specs, I need it to go through the specs.sh script within that project.

To accomplish that, I add the following to the top line of each spec:

    #!/usr/bin/env jasmine-node --forceexit