Skip to content

Instantly share code, notes, and snippets.

@calvincorreli
Created February 7, 2014 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calvincorreli/8862423 to your computer and use it in GitHub Desktop.
Save calvincorreli/8862423 to your computer and use it in GitHub Desktop.
Improved it a bit, so it says what it's doing, and defaults to master when there's no branch-specific setting
#! /bin/zsh
branch_name=${$(git symbolic-ref HEAD)#refs/heads/}
function switch {
echo "Switching to database.yml.branch.${1}"
cp config/database.yml config/database.yml.branch.bak
cp config/database.yml.branch.${1} config/database.yml
}
if [ -f config/database.yml.branch.${branch_name} ]; then
echo "Switching to database.yml.branch.${branch_name}"
switch ${branch_name}
else
switch 'master'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment