Rails .bash_profile (.bashrc)

17 Apr 2006

If you use Subversion and develop Rails on either Linux, Mac OS X, or through a shell into a shared server you could use this.

A while ago I realized that many of the commands I was using on a regular basis were cumbersome. With Subversion especially I found the commands lengthy. With Rails I kept wanting a ‘remigrate’ command so I could test my migrations to see if they were valid all the way down to 0 and back up. To edit your .bashrc or .bash_profile entries simply type:

nano ~/.bash_profile
# (you can replace 'nano' with whatever editor you like).  You can add as many other aliases as you want to help with whatever commands you use most - just make sure there are no spaces on either side of the equals sign!

The following is the text from my .bash_profile file in my home directory:

    alias migrate='rake migrate'
    alias clone='rake clone_structure_to_test'
    alias remigrate='rake migrate VERSION=0 && rake migrate'
    alias remigrate_prod='rake migrate VERSION=0 RAILS_ENV=production && rake migrate RAILS_ENV=production'
    alias remigrate_dev='rake migrate VERSION=0 RAILS_ENV=development && rake migrate RAILS_ENV=development'
    alias l='ls -l'
    alias st='svn st'
    alias update='svn update'
    alias delete='svn delete'
    alias add='svn add'
    alias copy='svn copy'
    alias move='svn move'
    alias commit='svn commit'
    alias commitm='svn commit -m ""'
    alias upcom='svn update && svn commit -m ""'
    alias upco='svn update && svn commit'

The following allows me to type just ‘update’ to do an svn update or ‘commitm’ if I want to commit without bothering to enter a log message (useful for one-person projects). ‘upcom’ and ‘remigrate’ are my two favorites because they allow for quick access to multiple commands.

Let me know if you have any others I should add to speed up my work!


Please if you found this post helpful or have questions.