Skip to content

Instantly share code, notes, and snippets.

@sheharyarn
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sheharyarn/f7559b375daed557c86d to your computer and use it in GitHub Desktop.
Save sheharyarn/f7559b375daed557c86d to your computer and use it in GitHub Desktop.
Rails Server Shortcuts

Rails Server Shortcuts

Running this script will create three shortcuts (aliases) on your Server:

  • rc - Runs rails console in production
  • cdapp - CDs you into the current release of your app (capistrano)
  • applogs - Starts tailing the production.log of the current release of your app.

This script follows the ~/apps/appname/current directory structure.

To Install:

bash -c "$(curl -fsSL https://gist.githubusercontent.com/sheharyarn/f7559b375daed557c86d/raw/29cce33943edbf3794e9386c84e44a474139d2b5/server_shortcuts.sh)"
#!/bin/bash
# Server Shortcuts - By Sheharyar
SHORTCUTS_FILE="$HOME/.server_shortcuts.sh"
# Getting app name
echo -n "Enter your App Name: "
read APPNAME
# Creating a file for saving shortcuts
echo "# Server Shortcuts - By Sheharyar" > $SHORTCUTS_FILE
chmod +x $SHORTCUTS_FILE
echo "Adding Shortcut: rc"
echo "alias rc='bundle exec rails c production'" >> $SHORTCUTS_FILE
echo "Adding Shortcut: cdapp"
echo "alias cdapp='cd $HOME/apps/$APPNAME/current'" >> $SHORTCUTS_FILE
echo "Adding Shortcut: applogs"
echo "alias applogs='tail -f $HOME/apps/$APPNAME/current/log/production.log'" >> $SHORTCUTS_FILE
# Linking shortcuts file in .bash_profile
echo "source $SHORTCUTS_FILE" >> $HOME/.bash_profile
source $HOME/.bash_profile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment