Skip to content

Instantly share code, notes, and snippets.

@mattantonelli
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save mattantonelli/9d060fcc49d853bdda22 to your computer and use it in GitHub Desktop.

Select an option

Save mattantonelli/9d060fcc49d853bdda22 to your computer and use it in GitHub Desktop.
Open the latest migration for a Rails application in VIM
# Add to your .zshrc
# find git home directory
function find-git-home() {
git rev-parse --show-toplevel
}
# find the filename of the last migration based on file timestamp
function last-migration() {
ls -rt `find "$(find-git-home)/db/migrate" -type f -name "*" -print` | tail -1
}
# commands on last migration
alias vlmg='vim "$(last-migration)"'
alias rmlmg='rm "$(last-migration)"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment