Howdy, fellow geekster. I'm Robin Curry, and I mostly blog about Ruby, Rails, jQuery, css, development, and web design.


Follow me on twitter or grab my feed.

Chain Links #022

Posted: August 18th, 2009 | Author: robincurry | Filed under: Uncategorized | Tags: , , , , | Comments Off

Popularity: 31% [?]


Chain Links #020

Posted: August 13th, 2009 | Author: robincurry | Filed under: Uncategorized | Tags: , , , , | Comments Off

Popularity: 35% [?]


A better script/server alias for Rails

Posted: August 13th, 2009 | Author: robincurry | Filed under: Uncategorized | Tags: , | 1 Comment »

I’ve long had a bash alias for starting up script/server for a rails process that looked something like:

alias ss="./script/server"

This has worked all well and good, but I’ve been wanting more. I often find myself switching between projects and the time and effort it takes is just exhausting. I mean, think of all those keystrokes!

Inspired by @MikeG1′s tweet pining for a script/server to kill any other process running on same port, and a desire to make the switching process easier for myself, I came up with the following function that I added to my bash profile.

Now switching between rails apps is effortless. I can start the rails app from anywhere with no worries about conflicting processes (bye bye, you’ve been terminated) or even changing to the proper directory. Ahhh, my hands feel lighter already.

Enjoy!


# ss – A better script/server alias.
# Usage:
# ss <my_rails_app>
# Will
# – cd to the project directory (if argument provided, otherwise will use current directory)
# – kill any existing rails server instances
# – start the rails server

function ss {
  if [ "$1" ]; then
    # cd to the rails app directory.
    cd ~/proj/repos;  # (update the repository root location to suit your needs)
    if [ "$1" ]; then
      cd `ls|grep $1|sort|tail -1`
    fi
    echo $(pwd)
  fi
  # kill any existing rails server processes.
  ps -a|grep "ruby ./script/server"|grep -v "grep"|cut -d " " -f1|xargs -n 1 kill -TERM

  # start the server.
  ruby ./script/server
}

Popularity: 60% [?]


Chain Links #018

Posted: August 11th, 2009 | Author: robincurry | Filed under: Uncategorized | Tags: , , , , | Comments Off

Popularity: 17% [?]


Chain Links #017

Posted: August 10th, 2009 | Author: robincurry | Filed under: Uncategorized | Tags: , , | Comments Off

Popularity: 21% [?]


Chain Links #016

Posted: August 7th, 2009 | Author: robincurry | Filed under: Uncategorized | Tags: , , , | Comments Off

Popularity: 14% [?]


Chain Links #015

Posted: August 6th, 2009 | Author: robincurry | Filed under: Uncategorized | Tags: , , , | Comments Off

Popularity: 12% [?]


Chain Links #014

Posted: August 5th, 2009 | Author: robincurry | Filed under: Uncategorized | Tags: , , | Comments Off

Popularity: 15% [?]


Chain Links #013

Posted: August 4th, 2009 | Author: robincurry | Filed under: Uncategorized | Tags: , , , | Comments Off

Popularity: 19% [?]


Chain Links #012

Posted: August 3rd, 2009 | Author: robincurry | Filed under: Uncategorized | Tags: | Comments Off

Popularity: 8% [?]