-
-
Save rcmoret/6d232b708fb2d45be86a8e01e46e17aa to your computer and use it in GitHub Desktop.
Script for opening a rails console for an app within vagrant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
if [[ -z $1 ]]; then | |
APP_NAME=$(basename `pwd`) | |
else | |
APP_NAME=$1 | |
fi | |
echo "Opening Rails Console for $APP_NAME in vagrant..." | |
cd ~/vagrant && vagrant ssh -c "cd /pub/$APP_NAME/current && bundle exec rails console" |
This should drop you back out if you typo the app_name, rather than leave you sitting in the VM: vagrant ssh -c "cd /pub/$APP_NAME/current || exit; bundle exec rails console"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also, line 4:
pwd | sed 's,.*vagrant/code/\([^/]*\).*,\1,'
to make it work even when you're in a sub-directory.