Skip to content

Instantly share code, notes, and snippets.

@AggroBoy
Last active September 27, 2015 13:28
Show Gist options
  • Save AggroBoy/1277568 to your computer and use it in GitHub Desktop.
Save AggroBoy/1277568 to your computer and use it in GitHub Desktop.
#!/usr/bin/env zsh
# Set up RVM
if [[ -f $HOME/.rvm/scripts/rvm ]]; then
source "$HOME/.rvm/scripts/rvm"
elif [[ -f /etc/profile.d/rvm.sh ]]; then
source /etc/profile.d/rvm.sh
else
echo RVM not found
exit
fi
# Get the directory we're running in
DIR=$(dirname $(perl -e 'use Cwd "abs_path";print abs_path(shift)' $0))
rvm $(cat $DIR/.ruby-version)@$(cat $DIR/.ruby-gemset)
# Find some Ruby script to run based on the name of this script
if [[ -f $DIR/bin/$(basename $0).rb ]] then
ruby -I $DIR/lib $DIR/bin/$(basename $0).rb $@
elif [[ -f $DIR/bin/$(basename $0) ]] then
ruby -I $DIR/lib $DIR/bin/$(basename $0) $@
else
echo 'so, um...?'
fi
@AggroBoy
Copy link
Author

Second revision allows target Ruby script to either have a .rb file extension, or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment