Last Updated: February 25, 2016
·
617
· sgibbons

Bash alias for last rails migration

Due to the timestamp_name.rb format of migrations, tab completion is a nightmare. To help combat this, I throw this handy little alias in my .bashrc:

alias lastmig='echo db/migrate/`ls db/migrate -lt | head -n 2 | tail -n 1 | rev | cut -d " " -f 1 | rev`'

This allows, so long as I'm in the rails root of my app, for quick access to the most recent migration (and likely the one that I'm actively working on):

$ vim `lastmig`

1 Response
Add your response

sweet, always wondered, why its not titletimestamp.rb instead of timestamptitle.rb ... would be a lot of handier :/

thanx for the alias!

over 1 year ago ·