Created
September 23, 2012 05:22
-
-
Save slumos/3768957 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| #! /usr/bin/env zsh | |
| user="$1" | |
| env="$2" | |
| function usage { | |
| cat <<EOF 2>&1 | |
| usage: ru rails_user rails_env command args... | |
| Run command as rails_user with RAILS_ENV=rails_env. | |
| Also copies invoking user's PATH into the target env. | |
| e.g. ru wgadmin production rails console | |
| ru integritie production rake unicorn:status | |
| EOF | |
| } | |
| if [[ -z "$user" || -z "$env" ]]; then | |
| usage | |
| exit 1 | |
| fi | |
| shift 2 | |
| sudo -u "$user" /usr/bin/env "PATH=$PATH" "RAILS_ENV=$env" bundle exec $* |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment