May 07 2010

Command aliases for Subversion, Git and Rails

Subversion Git Rails Ruby Mac CommandLine | comments

I got a Peepcode unlimited last year which came with a nice video about the command line. Check it out.

Not too many people will find this interesting. For me, it's something I just want to do for myself (and for those I'd work for if I'm still employed).

Aliases matter

I haven't organized my aliases into a separate file as shown in the video but I am using some useful aliases right now.

These are some of the aliases I have:

              alias start_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM start"
              alias stop_mysql="/Library/StartupItems/MySQLCOM/MySQLCOM stop"
              #adds all new and modified files for a git repository
              alias ga="git add ."
              #adds all new files for subversion 
              alias sa="svn status | grep "^\?" | sed -e 's/? *//' | sed -e 's/ /\\ /g' | xargs svn add"
              

I find Rails 3 commands much more confusing than the old ones although they seem to be nearly the same. Plus it gets a little complex considering I'm using different versions. For those following through my posts regarding Rails on OS X/ Linux, you'd probably find this useful.

              #The new command to install a plugin in Rails 3 (subject to change - probably) 
              ruby script/rails plugin install plugin_repository
              

A little long right? This is what I need for sanity:

              alias plugin_install="ruby script/rails plugin install"
              #use Rails3 for Ruby 1.8.7 
              alias r3="rvm 1.8.7%rails3"
              #use Rails3 version and starts the rails app
              alias rs="rvm 1.8.7%rails3 && rails server"
              

Sweet. Now I can sleep. Zzzz...